本文介绍了当插入一行时,我得到一个错误,上面写着“将数据类型nvarchar转换为int时出错”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
try
{
SqlDataAdapter daa = new SqlDataAdapter("select max(idcat) from category", con);
DataSet ds = new DataSet();
daa.Fill(ds, "category");
DataView dvv = new DataView(ds.Tables["category"]);
DateTime date = System.Convert.ToDateTime(dateTimePicker1.Text);
int numsup;
numsup = int.Parse(comboBoxSppNo.Text);
//MessageBox.Show(numsup.ToString());
SqlCommand cmd3 = new SqlCommand("exec insertparts @partnumber,@description,@date,@quantity,@unitPrice,@AddnewQty,untpnewQty,@vat,@suppId", con);
cmd3.Parameters.AddWithValue("@partnumber",txtPartNo.Text);
cmd3.Parameters.AddWithValue("@description", txtDesc.Text);
cmd3.Parameters.AddWithValue("@date", date);
cmd3.Parameters.AddWithValue("@quantity", txtEntrance.Text);
cmd3.Parameters.AddWithValue("@unitPrice", txtunitprice.Text);
cmd3.Parameters.AddWithValue("@AddnewQty", 0);
cmd3.Parameters.AddWithValue("@untpnewQty", 0);
cmd3.Parameters.AddWithValue("@vat", txtvat.Text);
// cmd3.Parameters.AddWithValue("@desccat", txtDesc.Text);
cmd3.Parameters.AddWithValue("@suppId", numsup);
con.Close();
con.Open();
cmd3.ExecuteNonQuery();
MessageBox.Show("SUCCESSFULL INSERT");
推荐答案
cmd3.Parameters.AddWithValue("@partnumber",txtPartNo.Text);
cmd3.Parameters.AddWithValue("@description", txtDesc.Text);
cmd3.Parameters.AddWithValue("@quantity", txtEntrance.Text);
cmd3.Parameters.AddWithValue("@unitPrice", txtunitprice.Text);
cmd3.Parameters.AddWithValue("@vat", txtvat.Text);
try
{
SqlDataAdapter daa = new SqlDataAdapter("select max(idcat) from category", con);
DataSet ds = new DataSet();
daa.Fill(ds, "category");
DataView dvv = new DataView(ds.Tables["category"]);
DateTime date = System.Convert.ToDateTime(dateTimePicker1.Text);
int numsup;
numsup = int.Parse(comboBoxSppNo.Text);
//MessageBox.Show(numsup.ToString());
SqlCommand cmd3 = new SqlCommand("insertparts", con);
cmd3.CommandType = CommandType.StoredProcedure;
cmd3.Parameters.AddWithValue("@partnumber", txtPartNo.Text);
cmd3.Parameters.AddWithValue("@description", txtDesc.Text);
cmd3.Parameters.AddWithValue("@date", date);
cmd3.Parameters.AddWithValue("@quantity", txtEntrance.Text);
cmd3.Parameters.AddWithValue("@unitPrice", txtunitprice.Text);
cmd3.Parameters.AddWithValue("@AddnewQty", 0);
cmd3.Parameters.AddWithValue("@untpnewQty", 0);
cmd3.Parameters.AddWithValue("@vat", txtvat.Text);
// cmd3.Parameters.AddWithValue("@desccat", txtDesc.Text);
cmd3.Parameters.AddWithValue("@suppId", numsup);
con.Close();
con.Open();
cmd3.ExecuteNonQuery();
MessageBox.Show("SUCCESSFULL INSERT");
}
这篇关于当插入一行时,我得到一个错误,上面写着“将数据类型nvarchar转换为int时出错”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!