Code Snippet
private void button1_Click(object sender, EventArgs e)
string connstr = "Persist Security Info=False;Integrated Security=SSPI;" +
"Initial Catalog=Northwind;server=localhost";
SqlConnection conn = new SqlConnection(connstr);
string sql = "INSERT INTO TestTable(col1,col2,col3) VALUES(@c1,@c2,@c3)";
SqlCommand cmd = new SqlCommand(sql, conn);
//col1, col2, col3 are columns of the DataTable
"@c1", SqlDbType.VarChar, 255, "col1");
"@c2", SqlDbType.VarChar, 255, "col2");
"@c3", SqlDbType.VarChar, 255, "col3");
SqlDataAdapter da = new SqlDataAdapter();
//dt is a DataTable
You can use the TableAdapter object, specifyInsertCommand and UpdateCommand for it, and call the Update() method toupdate the tables, for more information about this and sample codes, check the following documents:
How to: Bind Data to the Windows Forms DataGridView Control
TableAdapter Overview