C#.net .. I am not getting how to read values from datagridview columns and rows and insert them in sql server db table..............
string str2= Convert.ToDecimal(row.Cells[3].Value);
i am not getting, how to write proper code for that .........
this my code of application .....
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "Insertsalesorder";
cmd.CommandType = CommandType.StoredProcedure;
dataGridView1.DataSource = ds.Tables[0];
DataTable dt = new DataTable();
DataRow dr = ds.Tables[0].NewRow();
dr[0] = txtsbill.Text;
dr[1] = txtsgrandtot.Text;
dr[2] = cbscust.SelectedItem;
dr[3] = txtshmm.Text;
ds.Tables[0].Rows.Add(dr);
MessageBox.Show("Record Added");
if(ds.Tables[0].Rows.Count >0)
//ds.Tables[0].Rows[rno][1] = textBox2.Text;
//ds.Tables[0].Rows[rno][2] = textBox3.Text;
//ds.Tables[0].Rows[rno][3] = textBox4.Text;
//MessageBox.Show("Record Modified");
// string str3 = Convert.ToDecimal(row.Cells[4].Value);
cmd.Parameters.AddWithValue("@Billno1", txtsbill.Text);
cmd.Parameters.AddWithValue("@Custname1",cbscust.SelectedItem);
cmd.Parameters.AddWithValue("@Dateofsale1", mtxtdate.Text);
cmd.Parameters.AddWithValue("@HammaliCharge1", txtshmm.Text);
cmd.Parameters.AddWithValue("@TotalAmount1", txtstotamt.Text);
cmd.Parameters.AddWithValue("@SaleTaxPer1", txtstaxper.Text);
cmd.Parameters.AddWithValue("@TaxAmt1 ", txtsaftertaxamt.Text);
cmd.Parameters.AddWithValue("@GrandTotal1", txtsgrandtot.Text);
}
plz provide me the write code for that ....
is there any way to post snap shot or image of my C# form page with this question ........
so it will be useful for understanding the problem..........