OleDbConnection con=DB.CreateCon ();
OleDbCommand cmd=new OleDbCommand ( "Insert into [User]([UserName],[Password])values(@UserName,@Password) ",con);
OleDbParameter PUserName=new OleDbParameter ( "@UserName ",OleDbType.VarChar ,10);
PUserName.Direction=ParameterDirection .Input ;
PUserName.Value =this.UserName.Text ;
cmd.Parameters.Add (PUserName);
OleDbParameter PPassword=new OleDbParameter ( "@Password ",OleDbType.VarChar ,50);
PPassword.Direction =ParameterDirection .Input ;
PPassword.Value =this.Password.Text;
cmd.Parameters.Add (PPassword);
con.Open ();
cmd.ExecuteNonQuery();
con.Close ();
Response.Write ( "注册成功,您已经成为我们的会员了. ");
------解决方案--------------------------------------------------------
有错误信息吗?
------解决方案--------------------------------------------------------
ACCESS数据库 文件的属性为只读,或则文件是打开状态?
------解决方案--------------------------------------------------------
报什么错?
------解决方案--------------------------------------------------------
可以肯定这段代码是没有问题的:
OleDbCommand cmd=new OleDbCommand ( "Insert into [User]([UserName],[Password])values(@UserName,@Password) ",con);
OleDbParameter PUserName=new OleDbParameter ( "@UserName ",OleDbType.VarChar ,10);
PUserName.Direction=ParameterDirection .Input ;
PUserName.Value = this.UserName.Text ;
cmd.Parameters.Add (PUserName);
OleDbParameter PPassword=new OleDbParameter ( "@Password ",OleDbType.VarChar ,50);
PPassword.Direction =ParameterDirection .Input ;
PPassword.Value = this.Password.Text;
cmd.Parameters.Add (PPassword);
con.Open ();
cmd.ExecuteNonQuery();
con.Close ();
Response.Write ( "注册成功,您已经成为我们的会员了. ");
------解决方案--------------------------------------------------------
注意access不要只读.另外要有写入access文件的权限.
------解决方案--------------------------------------------------------
你先在web.config中使用身份模拟试试? <identity impersonate= "true " userName= "administrator " password= "233333333 "/> </system.web>