C# 在ACCESS中插入记录???窗体程序中操作ACCESS
这是我的部分语句:
//数据库连接
mycnn = new OleDbConnection(@ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\menu.mdb ");
mycnn.Open();
OleDbCommand aCommand = new OleDbCommand( "select * from menu ", mycnn);
OleDbDataReader aReader = aCommand.ExecuteReader();
可以连接上,也可以通过READER读出来,
就是在写入时,也不报错,也写不进去,///???????????
String sSQL = "INSERT INTO menu(Numbe,Menutype) VALUES (5, 'Bob ') ";
OleDbCommand myCommand = new OleDbCommand(sSQL, mycnn);
myCommand.ExecuteNonQuery();
请前辈们指点指点吧,我是不是用的不对,我在网上找到的东西都是在WEB中操作ACCESS,我想在窗体上操作,要怎么写呀,在C#.NET2005中,?????????????????????????在窗体程序中操作ACCESS
------解决方案--------------------try
{
mycnn.open();
String sSQL = "INSERT INTO menu(Numbe,Menutype) VALUES (5, 'Bob ') ";
OleDbCommand myCommand = new OleDbCommand(sSQL, mycnn);
myCommand.ExecuteNonQuery();
}
catch(Exception ex)
{
MessageBox.show(ex.ToString());
}
finally
{
mycnn.close();
}