473,595 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,datatab les and
sqlAdapter

Thanks

Jun 27 '08 #1
4 4763
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,datatab les 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*******@yaho o.NoSpamMaam.co mwrote in message
news:78******** *************** ***********@mic rosoft.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,datatab les 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 ContinueUpdateO nError 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*******@yaho o.NoSpamMaam.co mwrote in message
news:78******** *************** ***********@mic rosoft.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,datatab les and
sqlAdapter

Thanks



Jun 27 '08 #4
thanks for the help peter

"daveL" <ve***********@ yahoo.comwrote in message
news:nf******** *********@newss vr19.news.prodi gy.net...
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,datatab les and
sqlAdapter

Thanks

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2240
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the DataTable first and I then want to roll through the DataTable while in memory checking for errors and then commit the rows to my database table (btw this is in ASP.NET). Is it possible to have data in a datable before attaching at DataAdapter? I'm a...
1
4923
by: MrMike | last post by:
I have the following code which allows me to display records from a table named "lkup_Specie" in a datagrid. If I create a second datatable and a second hashtable for a table named "lkup_Grade", how would I incorporate that logic into my existing logic? Would it go after Next statement? Thanks. Protected specieDataTable As New DataTable 'BEING USED OK Protected specieHashTable As New Hashtable 'BEING USED OK Protected cutDataTable...
1
2014
by: cindy | last post by:
Get data into datatable, add to dataset dsSearch " Get data into datatable, add to dataset dsSearch Using In-Memory SQL Engine join the tables and select the filenames from the join, add to dataset dsSearch CODE ON http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3994&lngWId=10 using SQL connection get data from view on sql server, add to dataset dsSearch
4
4314
by: slaprade | last post by:
I am loading a weeks worth of web logs into a dataset using Imports Microsoft.Data.Odbc These are text - fixed length fields so I have written a schema for them. The adapter fill looks like this Dim dt As New DataTable() Dim cnString As String Dim adapter As New OdbcDataAdapter() Dim qs1 As String = "Select * from dl" 'first part of query .... .... ....
6
1696
by: Danny Ni | last post by:
Hi, If I want to programatically add rows to a DataTable, do I call AcceptChanges per row? Or do I call AcceptChanges after all rows added? TIA
10
6521
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I have one querie that grabs all of the id's I need for the other 4 queries, but I am not sure how to get them into a DataTable or DataSet, or if that is the best way to do this. Seperately the queries all work with no problems.
1
1650
by: Niron kag | last post by:
Hi, I try to get a dataTable from the DB , add it a row and update it back to the DB. The program does not throw exception but the DB is not updated. Can you please help me and tell me what I do wrong? Thanks in advance! public static void setOprjTableRow(string DBname , DataRow OPRJUpRow) {
6
16728
by: Nick | last post by:
I have a code that returns data in IList. My webGrid doesn't allow me to sort with IList returned, it say it only suports DataView, DataTable and DataSet, not IEnumerable. I don't know how to return the DataSet type when using the following code: ======== this is my interface ====================== namespace WareHouse.DataLayer.DataObjects { /// <summary> /// Defines methods to access categories and products.
0
1764
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: //=================================================================== // The table
2
5205
by: Tina | last post by:
Can I use a sqlDataSource to fill a datatable in code? How? Thanks, T
0
8261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8019
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8251
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6674
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1490
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.