Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dataGridView1.Rows[rowIndex].Cells[columnIndex].Value = value;
- dataGridView1.Rows[rowIndex].Cells[columnIndex].Value = value;
- this.dataGridView1.Rows.Add();
- this.dataGridView1.Rows[0].Cells[1].Value = "1";
- this.dataGridView1.Rows[0].Cells[2].Value = "Baqar";
- // dgvBill is name of DataGridView
- string StrQuery;
- try
- {
- using (SqlConnection conn = new SqlConnection(ConnectingString))
- {
- using (SqlCommand comm = new SqlCommand())
- {
- comm.Connection = conn;
- conn.Open();
- for (int i = 0; i < dgvBill.Rows.Count; i++)
- {
- StrQuery = @"INSERT INTO tblBillDetails (IdBill, productID, quantity, price, total) VALUES ('" + IdBillVar+ "','" + dgvBill.Rows[i].Cells[0].Value + "', '" + dgvBill.Rows[i].Cells[4].Value + "', '" + dgvBill.Rows[i].Cells[3].Value + "', '" + dgvBill.Rows[i].Cells[2].Value + "');";
- comm.CommandText = StrQuery;
- comm.ExecuteNonQuery();
- }
- }
- }
- }
- catch (Exception err)
- {
- MessageBox.Show(err.Message , "Error !");
- }
- //dataGridView1.Rows[RowCount].Cells[0].Value = FEString3;//This was not adding Stringed Numbers like "1","2","3"....
- DataGridViewCell NewCell = new DataGridViewTextBoxCell();//Create New Cell
- NewCell.Value = FEString3;//Set Cell Value
- DataGridViewRow NewRow = new DataGridViewRow();//Create New Row
- NewRow.Cells.Add(NewCell);//Add Cell to Row
- dataGridView1.Rows.Add(NewRow);//Add Row To Datagrid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement