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 4 4726
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
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
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
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 This discussion thread is closed Replies have been disabled for this discussion. Similar topics
5 posts
views
Thread by randy |
last post: by
|
1 post
views
Thread by MrMike |
last post: by
|
1 post
views
Thread by cindy |
last post: by
|
4 posts
views
Thread by slaprade |
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
|
6 posts
views
Thread by Nick |
last post: by
|
reply
views
Thread by Maart_newbie |
last post: by
|
2 posts
views
Thread by Tina |
last post: by
| | | | | | | | | | |