for (j = 0; j < i; j++) { //MessageBox.Show(dataGridView1.Rows[j].Cells["Column8"].Value.ToString()); if (Convert.ToBoolean(dataGridView1.Rows[j].Cells["Column8"].Value) == true) { using (SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\tahathegreat\Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\TT.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")) { conn.Open(); using (SqlCommand cmd = new SqlCommand("UPDATE [UInfo] SET [Checked]=@chk" + " WHERE SAPNo=@sno", conn)) { cmd.Parameters.AddWithValue("@chk", "1"); cmd.Parameters.AddWithValue("@sno", dataGridView1.Rows[j].Cells["Column5"].Value); int rows = cmd.ExecuteNonQuery(); //rows number of record got updated } conn.Close(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)