varsha dodiya

varsha dodiya

  • NA
  • 407
  • 75.2k

insert data in sql table in C#

Jul 10 2014 2:13 AM
when i insert data it throws exception "erroe converting datatype nvarchar to numeric"  plz help me in fixing this. 
  private void btnSave2_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("insert into PRO_BILL (S_name,P_billno,P_ch_no,P_pur_date,P_btotal,P_tovat,P_dis,P_gt,P_paid) values (@S_name,@P_billno,@P_ch_no,@P_pur_date,@P_btotal,@P_tovat,@P_dis,@P_gt,'n')", conn);
conn.Open();
cmd.Parameters.AddWithValue("@S_name", tbSupname.Text);
cmd.Parameters.AddWithValue("@P_billno", tbBILLNO.Text);
cmd.Parameters.AddWithValue("@P_ch_no", tbCHLNno.Text);
cmd.Parameters.AddWithValue("@P_pur_date", Convert.ToDateTime(dateTimePicker1.Text));
cmd.Parameters.AddWithValue("@P_btotal", tbtot1.Text);
cmd.Parameters.AddWithValue("@P_tovat", tbVAT.Text);
cmd.Parameters.AddWithValue("@P_dis", tbDisTOT.Text);
cmd.Parameters.AddWithValue("@P_gt", tbGT.Text);
cmd.ExecuteNonQuery();
conn.Close();
}
 

Answers (21)