|
-
Sep 7th, 2010, 04:46 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] SqlBulkCopy from DataGridView
I have a .csv file that is selected using the OpenFileDialog that then populates a DataGridView. The .csv file is then visible for the user to check a number of things. This part works fine.
What I then need is once it is checked the user then needs to click a button to import this into my SQL Server table (CSV_Import). I have looked at SQLBulkCopy but am failing to get the data imported.
Here is some code I have picked up and I am guessing that it is the bc.WriteToServer(dt) needs correcting within the brackets but I am at a loss at this point.
bc.BatchSize = dt.Rows.Count
bc.DestinationTableName = "CSV_Import"
bc.WriteToServer(dt)
bc.Close()
myConnection.Close()
Please advise, thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|