Using VB.Net
I want to get a all datagrid cell values, then insert into table1.
Code
cmd = New SqlCommand("insert into table1 values('" & DataGrid.Rows(0).Cells(0).Value & "', '" & DataGrid.Rows(0).Cells(1).Value & "', '" & DataGrid.Rows(0).Cells(2).Value & "', '" & DataGrid.Rows(0).Cells(3).Value & "')", con)
cmd.ExecuteNonQuery()
The above code is inserting first row of datagrid cell value, but i want to insert all the datagrid cell values
How to modify my code for getting all the datagrid cell value.
Sticking to your existing code, despite its flaws (definatly look up: SQL Injection)
You could do somthing like this:
There’s numerous improvements that could be made but this answers your question: