ExecuteNonQuery 要求已打开且可用的 Connection。连接的当前状态为已关闭。 求解答
if(textBox2.Text==""||textBox3.Text==""||textBox4.Text==""){MessageBox.Show("货品信息不能为空...
if (textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")
{
MessageBox.Show("货品信息不能为空");
}
else
{
SqlConnection con = new SqlConnection("Server=.;database=wms;uid=sa;pwd=123");
SqlCommand con1 = new SqlCommand("insert carinfo values('" + textBox1.Text.ToString() + "','" + textBox2.Text.ToString() + "','" + label5.Text.ToString() + "','" + textBox4.Text.ToString() + "','" + textBox3.Text.ToString() + "')", con);
con1.ExecuteNonQuery();
} 展开
{
MessageBox.Show("货品信息不能为空");
}
else
{
SqlConnection con = new SqlConnection("Server=.;database=wms;uid=sa;pwd=123");
SqlCommand con1 = new SqlCommand("insert carinfo values('" + textBox1.Text.ToString() + "','" + textBox2.Text.ToString() + "','" + label5.Text.ToString() + "','" + textBox4.Text.ToString() + "','" + textBox3.Text.ToString() + "')", con);
con1.ExecuteNonQuery();
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询