Re: datatable and sql Adapter



If your database has the correct referential integrity already set up, you
cannot violate it. You can set the ContinueUpdateOnError property on the
DataAdapter, and examine the row errors collection after the update completes
to see which rows weren't inserted because of integrity / restraint
violations.
-- Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site: http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://ittyurl.net


"daveL" wrote:

Im Inserting into Datatables From a Text File
SqlServer does Not know this is happening
I dont have a Problem setting up the relationship
disconnected...the problem is how to NOT violate primary key/ identity
keyss, when inserting the new data to the database using sqladapter

Thanks
Dave



"Peter Bromberg [C# MVP]" <pbromberg@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:78B5ECDB-EFC0-41C2-9A3A-F1BC4FA3ACC3@xxxxxxxxxxxxxxxx
when you select in the data for the parent and child tables, your parent
table will need a primary key ID column, and the child table will need a
"parentID" column that matches which row in the parent table the child row
is
associated with.
Then, when you've got your 2 tables in your DataSet, you create a
DataRelation to enforce the relationship.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net


"daveL" wrote:

Hello,
c#2 , sqlserver 2005

I am parsing a Text File into 2 Datatables
Parent we'll say invoice
child well say Invoice Items

parent rows 10,000, child rows 30,000
the 2 Tables start out Empty, i get the table structures from the
Database
"select top 0 from parenttable")
same for the items Table, then i parse the text file into
the 2 Datatables Disconnected from Server

My question is....when inserting into the database
how am i to get the child rows (items) the id key of the parent to
complete
the relation in a Batch Update

or do i need to make dynamic sql with @@identity
and insert 1 row Parent set child ids then insert the child rows

is there a example of how to accomplish this with dataset,datatables and
sqlAdapter

Thanks







.



Relevant Pages

  • Re: Updating and Retrieving Data
    ... How do I keep pending parent and children in synch? ... that actually exist in the database. ... use those placeholder values for your pending child rows. ... "SELECT SCOPE_IDENTITY" query to retrieve the last identity ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: Parent-Child relations in a dataset
    ... How do I keep pending parent and children in synch? ... that actually exist in the database. ... use those placeholder values for your pending child rows. ... "SELECT SCOPE_IDENTITY" query to retrieve the last identity ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Transfer Master / Detail Data (adding with new identity value)
    ... Ok so if I read you correctly you want to import Parent and child rows from ... databases into a centralised database but maintain the link from the source ... databases in the destination. ... how can I ADD the master/detail data from the second DB ...
    (microsoft.public.sqlserver.dts)
  • Re: datatable and sql Adapter
    ... Im Inserting into Datatables From a Text File ... Parent we'll say invoice ... how am i to get the child rows the id key of the parent to ...
    (microsoft.public.dotnet.languages.csharp)
  • Deadlocks and DataSets general issue
    ... not to violate FK contraint in the database. ... We must insert parent records first and then ... delete from parent records second. ... 1-Client 1 locks child table ...
    (microsoft.public.dotnet.framework.adonet)