PC Review


Reply
Thread Tools Rate Thread

DataTable.Add dataconstraintexception

 
 
Ady
Guest
Posts: n/a
 
      25th Aug 2004
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


 
Reply With Quote
 
 
 
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      25th Aug 2004
Could you try removing the default (newid() ) from the guid column?

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Ady" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A DataTable-bound DataGridView throws a low-level Exception whencolumns are sorted, removed and re-added to the underlying DataTable. Sath123 Microsoft Dot NET Framework Forms 1 12th May 2008 12:51 PM
DataTable -> DataView -> Sort -> DataGrid : need related DataTable index Diamonds Microsoft ADO .NET 4 28th Jun 2006 08:23 PM
what is the best way to make a DataTable thread safe? DataTable.AcceptChanges() will throw exception (not documented) Ryan Liu Microsoft C# .NET 3 7th Jun 2006 05:07 PM
Retrieving datarows using DataTable.Select method and adding it to new DataTable C.Anand via DotNetMonster.com Microsoft ADO .NET 4 4th Apr 2005 05:21 PM
How can I use real SQL on a DataTable? i.e. not array of rows using a filter... as in DataTable.Select Dan V. Microsoft C# .NET 3 1st Jul 2004 03:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:16 PM.