PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Foreign key error, adding in liked tables
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Foreign key error, adding in liked tables
![]() |
Foreign key error, adding in liked tables |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

