C# access insert语句报错,求指点~
protected void Button1_Click(object sender, EventArgs e){
string goodsid1 = "'" + TextBox1.Text + "'";
string goodsname1 = "'" + TextBox2.Text + "'";
string price1 = "'" + TextBox3.Text + "'";
string unit1 = "'" + TextBox4.Text + "'";
string number1 ="'" + TextBox5.Text + "'";
string manufacture1 = "'" + TextBox6.Text + "'";
string manudate1 = "'" + TextBox7.Text + "'";
string sql1 = goodsid1 + "," + goodsname1 + "," + price1 + "," + unit1 + "," + number1 + "," + manufacture1 + "," + manudate1;
string sql = "insert into goods (goodsid,goodsname,price,unit,number,manufacture,manudate) values(" + sql1 + ")";
OleDbCommand cmd = new OleDbCommand(sql, conn);
if(cmd.ExecuteNonQuery()==0)
Label1.Text = "添加失败";
else
Label1.Text = "添加成功";
conn.Close();
}
数据库字段全为文本类型 --------------------编程问答-------------------- 把sql语句提取出来看看 --------------------编程问答-------------------- string sql = "insert into goods (goodsid,goodsname,price,unit,number,manufacture,manudate) values('"+TextBox1.Text+"','"+ TextBox2.Text +"','"+TextBox3.Text +"','"+TextBox4.Text+"','"+TextBox5.Text +"','"+TextBox6.Text+"','"+TextBox7.Text +"')";这样试试
还有你这个conn.open()木有
补充:.NET技术 , C#