ASP.NET操作ACCESS入门问题
private void Page_Load(object sender, System.EventArgs e)
{
string MyConn= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= "+Server.MapPath( "data/book.mdb ");//定义数据库连接参数
OleDbConnection MyConnection=new OleDbConnection(MyConn); //定义一个数据连接实例
MyConnection.Open();
string MyInsert= "insert into guestbook(name,tel,message)values( 'samson ', '0755-888888 ', '测试 ') ";
OleDbCommand MyCommand=new OleDbCommand(MyInsert,MyConnection);
Response.Write( "操作成功!! ");
}
刚学ASP.NET,想请教一下.运行没有错误, "操作成功!! "也输出了,写不进数据库,
但我不知道怎么弄,虽然这个问题太菜了,但我还是不会,没办法,请各位别笑我.我百度了,没搞定.谢谢各位.
------解决方案-------------------- OleDbCommand MyCommand=new OleDbCommand(MyInsert,MyConnection);
Response.Write( "操作成功!! ");
> > >
OleDbCommand MyCommand=new OleDbCommand(MyInsert,MyConnection);
MyCommand.ExecuteNonQuery(); // 此句执行插入
MyConnection.Close(); // 记得关闭连接
Response.Write( "操作成功!! ");
------解决方案--------------------MyConnection.Open();
string MyInsert= "insert into guestbook(name,tel,message)values( 'samson ', '0755-888888 ', '测试 ') ";
OleDbCommand MyCommand=new OleDbCommand(MyInsert,MyConnection);
MyCommand.ExecuteNonQuery();