dataset.Update impossible!

W

wavemill

I have this error, i don't know why!
Une exception non gérée du type 'System.InvalidOperationException'
s'est

produite dans System.Data.Common.dll

Informations supplémentaires : Dynamic SQL generation for the

UpdateCommand is not supported against a SelectCommand that does not

return any key column information.

My code:
string test = "Data Source =\\My Documents\\north.sdf" + ";Password=";
SqlCeConnection cn = new SqlCeConnection(test);
cn.Open();
DataSet ds2 = new DataSet();
SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM Products
WHERE

ProductID='" + productID + "'",cn);
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
SqlCeCommandBuilder cb2 = new SqlCeCommandBuilder(da);
da.Fill(ds2,"Products");
ds2.Tables["Products"].PrimaryKey = new DataColumn[]{

ds2.Tables["Products"].Columns["ProductID"]};


DataRow dr = ds2.Tables["Products"].Rows[0];
dr["UnitsInStock"] = actualNumericUpDown.Value;

da.Update(ds2,"Products");
ds2.AcceptChanges();
cn.Close();

Thank you

Wavemill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top