我試圖改變與MS Access數據庫密碼選項....錯誤:類型「System.Data.OleDb.OleDbDataReader」有沒有構造函數定義
請幫我人....
這裏的代碼: default.aspx.cs
protected void Button1_Click(object sender, EventArgs e)
{
try
{
OleDbConnection myCon = new OleDbConnection(ConfigurationManager.ConnectionStrings["vhgroupconnection"].ConnectionString);
myCon.Open();
string userid = txtuserid.Text;
string oldpass = txtoldpass.Text;
string newPass = txtnewpass.Text;
string conPass = txtconfirmpass.Text;
string q = "select user_id,passwd from register where user_id = @userid and passwd = @oldpass";
OleDbCommand cmd = new OleDbCommand(q, myCon);
OleDbDataReader reader = new OleDbDataReader();
cmd.Parameters.AddWithValue("@userid", txtuserid.Text);
cmd.Parameters.AddWithValue("@oldpass", txtoldpass.Text);
reader = cmd.ExecuteReader();
reader.Read();
if (reader["user_id"].ToString() != String.Empty && reader["passwd"].ToString() != String.Empty)
{
if (newPass.Trim() != conPass.Trim())
{
lblmsg.Text = "New Password and old password does not match";
}
else
{
q = "UPDATE register SET passwd = @newPass WHERE user_id [email protected]";
cmd = new OleDbCommand(q, myCon);
cmd.Parameters.AddWithValue("@newPasss", txtnewpass.Text);
cmd.Parameters.AddWithValue("@userod", txtuserid.Text);
cmd.Parameters.AddWithValue("@passwd", txtoldpass.Text);
int count = cmd.ExecuteNonQuery();
if (count > 0)
{
lblmsg.Text = "Password changed successfully";
}
else
{
lblmsg.Text = "password not changed";
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
還要檢查PLS .....
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0143: The type 'System.Data.OleDb.OleDbDataReader' has no constructors defined
源錯誤:
Line 36: OleDbCommand cmd = new OleDbCommand(q, myCon);
Line 37:
Line 38: OleDbDataReader reader = new OleDbDataReader();
Line 39:
Line 40:
+1但是也有一個非常錯誤的代碼的第二部分沒有檢查的結果reader.Read() – Steve
@Steve是的。更新了我的答案。謝謝。 –