Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I used password recovery control
and m retrieve mail id from sql server 2000 according to username

here is the code
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
    {
        try
        {
            string str = @"server=localhost;database=asp;uid=sa;pwd=sa";
            SqlConnection conn = new SqlConnection(str);
            conn.Open();
            String strcomand = "Select mailid from asp where name='" + PasswordRecovery1.UserName + "'";
            SqlCommand cmd = new SqlCommand(strcomand, conn);
            SqlDataReader reade = cmd.ExecuteReader();
            while (reade.Read())
            {
                string uname = reade["mailid"].ToString();
            }
        }
        catch (Exception gh)
        {
            Console.WriteLine(gh.StackTrace);
        }
}


but on submit button click the control does not do any thing
Posted
Updated 5-Mar-10 19:04pm
v4

1 solution

Have you read your piece of code? Where have you written anything that can show you in the UI that something was done?

Here are few suggestions:
1. Username will be unique, thus if it exists the related email-id would be only 1, which means at any point of time you will get o or 1 result. You should not use ExecuteReader for that. ExecuteScalar is good for you.

2. Once you get some result from the database i.e. email id then display that in the UI that some result was fetched. If you want to use it in othjer way then do it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900