i have one project in which i want to send forgot password mail but i am not able to find user name and password from the database it is sending blank mail like UserName : and Password : i want to find user name and password from the data base in 3 tier architecture thanks in advance and this is my code....
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"; }
}
Data Access Layer :
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;
}
DataSet ds =DataAccessLayer.ExeSelectQuery(sQuery);
try
{
if(ds .Tables[0].Rows.Count>0)
{
string sUserName = "";
string sPassword = "";
sUserName = ds.Tables[0].Rows[0]["Username"].ToString();
sPassword = ds.Tables[0].Rows[0]["Password"].ToString();
sendMail( sUserName, sPassword);
}
}
Hi Try this Hope It will help u..