string StrQuery; try { using (SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Demo_Data.mdf;Integrated Security=True;Connect Timeout=30")) { using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; conn.Open(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { StrQuery = @"INSERT INTO umrah (S#No#, Name, Code, Area, Sector, CNIC, TotalCoupen) VALUES ('" + dataGridView1.Rows[i].Cells["S#No#"].Value + "','" + dataGridView1.Rows[i].Cells["Name"].Value + "','" + dataGridView1.Rows[i].Cells["Code"].Value + "','" + dataGridView1.Rows[i].Cells["Area"].Value + "','" + dataGridView1.Rows[i].Cells["Sector"].Value + "','" + dataGridView1.Rows[i].Cells["CNIC"].Value + "','" + dataGridView1.Rows[i].Cells["TotalCoupen"].Value + "');"; comm.CommandText = StrQuery; comm.ExecuteNonQuery(); } } } } catch { }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)