从数据类型 varchar 转换为 numeric 时出错。?
private void btntianjia_Click(object sender, EventArgs e)
{
try
{
DataAccess ds=new DataAccess ();
string str = ds.connection();
con = new SqlConnection(str);
con.Open();
string Sql = "insert into ygjbtable(yggh,xingming,nianling,jiguan,shenfz,bumeng,zhiwei,jinctime,jbgz,gongb,jishi,lictime,bz) values('" + this.textBox1.Text + "','" + this.textBox2.Text + "','" + this.textBox3.Text + "','" + this.textBox4.Text + "','" + this.textBox5.Text + "','" + this.textBox6.Text + "','" + this.textBox7.Text + "','" + this.textBox8.Text + "','" + this.textBox9.Text + "','" + this.textBox10.Text + "','" + this.textBox11.Text + "','" + this.textBox12.Text + "','" + this.textBox13.Text + "')";
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = Sql;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
出错错误提示:从数据类型 varchar 转换为 numeric 时出错。
(字段里面只有gongb,jishi的数据类型是decimal类型)
------解决方案--------------------
decimal.Parse(this.textBox10.Text) + "','" + decimal.Parse((this.textBox11.Text )