|
-
Sep 21st, 2007, 01:13 PM
#1
Thread Starter
Member
SQL BULK INSERT FROM DataGridView
Hey all,
I need some help figureing out how to insert the contents of a datagridview into an SQL database table. some of the columns are databound and some are not. in otherwords, some columns i need to insert the "Value" of the cell while others i will need to insert the "Text" of the cell.
any suggestions?
-
Sep 21st, 2007, 03:53 PM
#2
Re: SQL BULK INSERT FROM DataGridView
Is your DGV databound? If it is, you just use a dataadapter to update the datatable that it is bound to. Otherwise, you have to loop thru the DGV rows and insert one at a time using a SqlCommand.
-
Sep 21st, 2007, 09:27 PM
#3
Re: SQL BULK INSERT FROM DataGridView
You should put all your data into a DataTable and then use a DataAdapter or TableAdapter to Update the source table from the DataTable. If you have bound and unbound columns in your grid then you should loop through all the rows of the grid and perform whatever processing is needed to get the unbound data into the remaining columns of the DataTable. You then just call Update on the adapter and pass the table. This assumes that your adapter has the appropriate InsertCommand and UpdateCommand properties for the data your DataTable contains.
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
|