I have two tables in my data base .
INV_HEAD and DN_HEAD
tables are given in below link
http://www.freeimagehosting.net/uploads/7dda8cd2c7.jpg[
^]]
I have combined two tables by "inner join" and show the data in grid view where LR_NO is null.
in the grid view I want to enter data of LR_NO and LR_DT (where null)
when i am updating data I am getting error data can not be updated in two tables.
can any one help me to update data ..
no need to update in 2 table update in DN_HEAD is enough
HERE MY CODE
public partial class Form2 : Form
{
SqlConnection con;
SqlDataAdapter da1;
SqlCommandBuilder cb;
DataSet ds;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
con = new SqlConnection("User Id=sa;Password=123;database=amar");
da1 = new SqlDataAdapter("SELECT dbo.INV_HEAD.INV_NO, dbo.INV_HEAD.INV_DT, dbo.DN_HEAD.DN_NO, dbo.DN_HEAD.DN_DT, dbo.DN_HEAD.LR_NO, dbo.DN_HEAD.LR_DT FROM dbo.INV_HEAD INNER JOIN dbo.DN_HEAD ON dbo.INV_HEAD.DN_NO = dbo.DN_HEAD.DN_NO where LR_DT IS NULL", con);
ds = new DataSet();
cb = new SqlCommandBuilder(da2);
da1.Fill(ds, "DN_HEAD,INV_HEAD");
dataGridView1.DataSource = ds.Tables["DN_HEAD,INV_HEAD"];
}
private void button1_Click(object sender, EventArgs e)
{
da1.Update(ds, "DN_HEAD,INV_HEAD");
MessageBox.Show("data saved");
}