System.Data.OleDb.OleDbConnection 并不包含 ExecuteNonQuary 的定义
今天我照别人的代码做了个数据更新的,可是在运行时却提示:System.Data.OleDb.OleDbConnection 并不包含 ExecuteNonQuary 的定义 源代码如下:
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);
oleconn.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(),"错误!");
}