我有一个项目,我想在其中发送忘记密码的邮件,但我无法从数据库中找到用户名和密码,它正在发送空白邮件,如用户名:和密码:我想从数据库中查找用户名和密码在 3 层架构中提前感谢,这是我的代码....
protected void Button1_Click(object sender, EventArgs e)
{
int id = MyRegistration.fgusername(txt_Email.Text.Trim());
if (id > 0)
{
string sQuery = "Select UserName, Password From Registration Where EmailID = '" + txt_Email.Text + "'";
DataSet ds =DataAccessLayer.ExeSelectQuery(sQuery);
try
{
string sUserName = "";
string sPassword = "";
sendMail( sUserName, sPassword);
}
catch (Exception ex) { }
}
else { label1.Text = "Invalid User"; }
}
数据访问层:
public static int fgusername(string sEmailId)
{
int id1 = 0;
string selectstr = "SELECT UserName, Password FROM Registration WHERE EmailID = '" + sEmailId.Trim() + "'";
id1 = DataAccessLayer.ExecuteReader(selectstr);
return id1;
}