Snaggers
asked on
Insert records from a Dataset
Using VB.net I have a dataset that I have populated from a CSV. [ds]
I would like to use this dataset to effectively run the following command
SELECT * INTO tblData FROM [ds]
Can this be done without iterating through the datarows property etc.. I would just like to run a one line insert statement.
Cheers
Td
I would like to use this dataset to effectively run the following command
SELECT * INTO tblData FROM [ds]
Can this be done without iterating through the datarows property etc.. I would just like to run a one line insert statement.
Cheers
Td
Put query to string and with loop add data from datagrid to text string (with correct query formating). When loop end just execute query on database.
ASKER
I've already worked it out using dr.AddRow etc, iterating through the columns, but it's not a pretty solution. Want to do it as just a one line SQL statement.
As i wrote, it is one line sql statement. But you need to make a while or for loop and add all data to sql statement string. After loop you will execute one sql statement against db.
ASKER
Ah ok, I see what you mean. But that will mean technically running x amount of INSERT statements.
I've found another way now using SQLBULKCOPY really powerful, as some of my columns don't match (don't ask, I never built either source or destination tables, just have to find a solution... ho hum).
Cheers
Td
I've found another way now using SQLBULKCOPY really powerful, as some of my columns don't match (don't ask, I never built either source or destination tables, just have to find a solution... ho hum).
Cheers
Td
I dont mean to run x amount of inserts :), you will create one string variable in your application session with whole sql statement and run only one insert sql statement against db. That's all.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.