数据库插入语法错误
我好不容易找了个能把数据插入数据库的方法,可是提示有语法错误!!郁闷!!
说是INSERT的语法错误,请高手看一下啊!!!
String s1= comboBoxIncome.Text.ToString();
String s2 = textBoxItem.Text.ToString();
String s4 = textBoxSum.Text.ToString();
String s3= richTextBoxRemark.Text.ToString();
try
{
if (s1 != "请选择类别" && s2 != "" && s3 != "" && s4 != "¥0")
{
String strconn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Data.mdb" ;
OleDbConnection oleconn = new OleDbConnection(strconn);
oleconn.Open();
String strInsert = "INSERT INTO InOut(收支,类别,项目,备注,金额(¥),日期)VALUE('收',s1,s2,s3,s4,System.DateTime.Now)";
OleDbCommand olecom = new OleDbCommand(strInsert,oleconn);
olecom.ExecuteNonQuary();
oleconn.Close();
DataSet ds = new DataSet();
BindingManagerBase myBind;
myBind=this.BindingContext[ds,"InOut"];
ds.Tables["InOut"].Rows[myBind.Position].BeginEdit();
ds.Tables["InOut"].Rows[myBind.Position].EndEdit();
ds.Tables["InOut"].AcceptChanges();
MessageBox.Show(s1 + "\n" + s2 + "\n" + s3 + "\n" + s4 + "\n" + "已加入数据库", "提示!");
}
else
MessageBox.Show("必须填满所有字段值!", "错误!");
}catch(Exception me)
{
MessageBox.Show("保存数据记录发生"+me.ToString(),"错误!");
}