469,269 Members | 1,006 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,269 developers. It's quick & easy.

datatable and sql Adapter

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

Jun 27 '08 #1
4 4702
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

Jun 27 '08 #2
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]" <pb*******@yahoo.NoSpamMaam.comwrote in message
news:78**********************************@microsof t.com...
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


Jun 27 '08 #3
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]" <pb*******@yahoo.NoSpamMaam.comwrote in message
news:78**********************************@microsof t.com...
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



Jun 27 '08 #4
thanks for the help peter

"daveL" <ve***********@yahoo.comwrote in message
news:nf*****************@newssvr19.news.prodigy.ne t...
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

Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by MrMike | last post: by
6 posts views Thread by Danny Ni | last post: by
10 posts views Thread by dauphian | last post: by
1 post views Thread by Niron kag | last post: by
reply views Thread by Maart_newbie | last post: by
2 posts views Thread by Tina | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.