0 hi,
i modified this line check it
ds1.Tables[0].Rows.Add(null,filename, s1, flag);
here identity is automatically increment so its showing error because this line trying to insert the in identity column with the filename field. so just pass the null value it will automatically increment the identity.
any problem reply
Mark it as answered if it helps you
Accepted 0 thanks
0 thanks it working.
cud you let me know the reason y ds1.AcceptChanges(); was not working
and one more query
if my database has a identity column (id,colum1,colum2,colum3)
ds1.Tables[0].Rows.Add(filename, s1, flag); //filename, s1,flag is variable gives error as it expects numeric value for identity column at filename. how can i update data in datatable so that it has identity value from database and on update its updates on database
0 hi,
i modified your code just check it.
DataSet ds1 = new DataSet();
SqlDataAdapter da1 = new SqlDataAdapter("select * from registrar_packets", con);
da1.Fill(ds1);
foreach(somthing)
{
ds1.Tables[0].Rows.Add(filename, s1, flag); //filename, s1,flag is variable
}
//here all data is filled in dataset ds1
SqlCommandBuilder objCommandBuilder = new SqlCommandBuilder(da1);
da1.Update(ds1.Tables[0]);
ds1.AcceptChanges();
any problem reply
if it helps you mark it as answered.