In my SQL Server 2008 R2 database, I have an existing table [dbo].[abc].[MyTable]. Now I want to read the rows from my DataGridView and merge them into MyTable.
Suppose I use a stored procedure.
I have no idea for looping through and merging rows.
Thanks for help.
private void saveRecords(DataGridView dgv)
{
foreach (DataGridViewRow row in dgv.Rows)
{
DataRow myRow = (row.DataBoundItem as DataRowView).Row;
// merge it to table in database.
}
}
You should use a command builder, take a look at this SqlCommandBuilder example .