AdoHelper问题
username = MyDataBace.MyDataBace.NoneEncrypt(txt_UserName.Text.Trim(), 1);
password = MyDataBace.MyDataBace.NoneEncrypt(txt_NewPassword.Text.Trim(), 1);
SqlStr = "update users set UserPassword=@UserPassword where UserName=@UserName ";
IDataParameter[] Param = new IDbDataParameter[2];
Param[0] = helper.GetParameter( "@UserName ", username);
Param[1] = helper.GetParameter( "@UserPassword ", password);
helper.ExecuteNonQuery(ConnStr, CommandType.Text, SqlStr, Param);
//OleDbConnection conn = new OleDbConnection(ConnStr);
//conn.Open();
//OleDbCommand cmd = new OleDbCommand(SqlStr, conn);
//cmd.Parameters.Add( "@UserPassword ", password);
//cmd.Parameters.Add( "@UserName ",username);
//cmd.ExecuteNonQuery();
用注释掉了的可以
[解决办法]
helper.ExecuteNonQuery(ConnStr, CommandType.Text, SqlStr, Param);
这句就行了,没有必要
conn.open()
你看下helper那个类,里面ExecuteNonQuery已经做好connection的open,close的方法,直接就行了,
返回datareader的时候记得datareader.close()一下,关闭连接,其它方法它会自己关掉的.