DataTable.Add dataconstraintexception

A

Ady

Hello

I'm loading in memory couple tables into a DataSet and then I try to add a
new row (in memory). This gives me an dataconstraintexception.
Here is the code:
//load dataset
SqlCeDataAdapter da = new SqlCeDataAdapter(request, connexionBD);
da.AcceptChangesDuringFill = false;
da.FillSchema(dataSet, SchemaType.Source, tableName);
da.Fill(dataSet, tableName);
da.Dispose();
-----------------------------
//insert a new second row
DataRow row = dataSet.Tables["Details"].NewRow();
row["details_guid"] = guid;
row["quantity"] = 0;
...
dataSet.Tables["Details"].Rows.Add(row);
-----------------------------
{"Column 'details_guid' is constrained to be unique. Value
'1f7b4edd-d5cd-43f9-b186-1907c67f82d8' is already present." }
even if I'm looking into the table and I can see that it still has only one
row (like before inserting the second row) and the guid is generated using
Win32 API and is different every time !

In SQL CE DB the column details_guid is default value: (newid()) and
isRowGuid: No.

Thank you
 

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