Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SqlDataAdapter da = new SqlDataAdapter("Select * from mytable", SqlConnection);

DataSet ds = new DataSet();
da.Fill(ds);

DataRow row1 = ds.Tables[0].NewRow();

row1["ID"] = 1;
row1["Name"] = "XYZ";

ds.Tables[0].Rows.Add(row1);

da.Update(ds);



Exception occurrs at the line : da.Update(ds);

Update requires a valid InsertCommand when passed DataRow collection with new rows.
Posted

1 solution

Hi,

Check the link below.

Inserting relational data using DataSet and DataAdapter[^]

Regards,
RK
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900