string strConn =@" Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source=c:\db.mdb; ";
OleDbConnection myConn = new OleDbConnection(strConn);
myConn.Open();
string strInsert = " INSERT INTO user ( 用户名 , 密码 , 联系地址 , Email地址 , 手机 ) VALUES ( ";
strInsert += this.tbusername .Text + ", '";
strInsert += this.tbpwd1 .Text + "', '";
strInsert += this.tbaddress .Text + "', ";
strInsert += this.tbemail .Text + ", ";
strInsert += this.tbphone .Text + ")";
OleDbCommand inst = new OleDbCommand(strInsert, myConn);
inst.ExecuteNonQuery();
myConn.Close();
OleDbConnection myConn = new OleDbConnection(strConn);
myConn.Open();
string strInsert = " INSERT INTO user ( 用户名 , 密码 , 联系地址 , Email地址 , 手机 ) VALUES ( ";
strInsert += this.tbusername .Text + ", '";
strInsert += this.tbpwd1 .Text + "', '";
strInsert += this.tbaddress .Text + "', ";
strInsert += this.tbemail .Text + ", ";
strInsert += this.tbphone .Text + ")";
OleDbCommand inst = new OleDbCommand(strInsert, myConn);
inst.ExecuteNonQuery();
myConn.Close();
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070212http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
如果还不行,就有可能是权限问题。
OleDbCommand inst = new OleDbCommand(strInsert, myConn);
用完的datareader要关闭。
OleDbConnection myConn = new OleDbConnection(strConn);
myConn.Open();
string strInsert = " INSERT INTO user ( 用户名 , 密码 , 联系地址 , Email地址 , 手机 ) VALUES ( '";
strInsert += this.tbusername .Text + "', '";
strInsert += this.tbpwd1 .Text + "', '";
strInsert += this.tbaddress .Text + "', '";
strInsert += this.tbemail .Text + "', '";
strInsert += this.tbphone .Text + "')";
OleDbCommand inst = new OleDbCommand(strInsert, myConn);
inst.ExecuteNonQuery();
myConn.Close();