Click here to Skip to main content
15,890,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,

i have gridview contains 10 records and one button name save when i click on save button all five records must be save in database at a time means batch mode.


please give me a solution.
Posted

you can loop through grid view recodes and call insert quarry inside the loop.

you can use foreach loop like this
C#
foreach (DataGridViewRow row  in dataGridView1.Rows)
{
    //do your insert inside this block.
}
 
Share this answer
 
v2
An efficient way to do batch insert is prepare xml from datagrid and then pass xml to stored procedure. Extract data from xml into stored procedure and insert data to database from stored procedure itself.


Hope this help!
 
Share this answer
 
Comments
Madhugundi 29-Mar-12 8:11am    
plz give me one example
Madhugundi 31-Mar-12 5:08am    
give me one example

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900