Bulk Insert Into Database with Relation

leedo2k

Active member
Joined
Nov 9, 2006
Messages
28
Programming Experience
Beginner
Hi,

I have a data base with two related tables:

Table A
GoupID
GroupName
GroupPath

Table B
PlayerID
PlayerName
GroupID

I also have a foreign key set by groupID so that all players are always created under a group.

Now,since the players are too many - over 300 - I need to make my application do a bulk upload for players using an external CSV files. The problem is that the user cannot know the FK so as to include it in the CSV file. So my intent is to intercept each row in the CSV and append the group ID after makeing sure that the user selects it in the GUI, in a combobox for example. Any ideas?
 
Read the DW2 link in my sig, if you never did data access the New Way before, then read Creating a Simple Data App.. Then read the sections about displaying and saving related data...

Basically, you'll make a stored procedure to insert the data into the parent... the sp will calc the FK and do the insert, and pass the calculated FK back out via a parameter. ADO.net will see this calculated value and update the local datatable. The update will cause the datarelation to update the child table. You can then insert the child table records normally. If this doesnt make sense, read the link and it will become clear
 
Back
Top