PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Foreign key error, adding in liked tables

Reply

Foreign key error, adding in liked tables

 
Thread Tools Rate Thread
Old 30-11-2005, 07:01 PM   #1
=?Utf-8?B?U2Ft?=
Guest
 
Posts: n/a
Default Foreign key error, adding in liked tables


Hi
I am using VS2005 VB, SQLexpress. I did some tests in a simple 2 table test
application where a parent table is linked to a child table. The data base is
designed with VS and the data access is made by a typed data set and
SQLdataAdapter (drag-drop database to a new dataset). Hence dataset and
adapters are generated by the DataSet Wizard.
I got a problem with foreign key contraints (SQL exception number = 547). I
tried a very lot of different ways to bring the simple thing running.

So far the result is reduced to the Update calls:
If correct = True Then
' update with data rows is used, is

TestInsertParentTableAdapter.Update(DS1.TestInsertParent.Select("", "",
DataRowState.Added))
Else
' update with data table (typed dataset) is used

TestInsertParentTableAdapter.Update(DS1.TestInsertParent.GetChanges(DataViewRowState.Added)) '
End If
TestInsertChildTableAdapter.Update(DS1.TestInsertChild) ' Add,
change or delete children
TestInsertParentTableAdapter.Update(DS1.TestInsertParent) '
Delete any remaining parents

Commet: If the parent table adapter is using the Update methode with the
DataRow() signature it works, if the Update methode with the DataTable
signature the next add of the child records will fail (no 547).

All other things are unchanged.

On the way to the mentioned result I coldn't find a succesful way either
using the datatable Update.

Any ideas what's wrong, has anybody similar results using C#?

Sam



  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off