troubleshooting Question

Trouble Retrieving Data

Avatar of asp_net2
asp_net2Flag for United States of America asked on
.NET ProgrammingC#ASP.NET
31 Comments1 Solution313 ViewsLast Modified:
Hello Experts,

I'm having trouble retrieving data on a page called resetpassword.aspx that needs to retrieve the users ID and Full name.

If a user forgets his/her password then they fill out their username and email address. An email will then be sent to the users email address with a link for them to click on which will look something like this http://programinfo/ghap/resertpassword.aspx?UsersID=21. When they click on that link I need to retrieve the users ID and Full Name on the resetpassword.aspx page. This is what I'm having trouble with.

I tested the Stored Procedure and it runs fine within SQL Server.

Please see my attached code for the resetpassword.aspx page.

protected void Page_Load(object sender, EventArgs e)
    {
        RetrieveUsersIDFullName();
    }

    protected void RetrieveUsersIDFullName()
    {
        int UsersID = Convert.ToInt32(Request.QueryString["users_id"]);

        using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HealthCourses"].ConnectionString))
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "HealthCourses_RetrieveUsersIDFullName";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = conn;

            cmd.Parameters.Add("@users_id", SqlDbType.Int).Value = hf_users_id;

            try
            {
                conn.Open();

                SqlDataReader rdr = cmd.ExecuteReader();

                if (rdr.Read())
                {
                    hf_users_id.Value = rdr["users_id"].ToString();
                    lblUsersFullName.Text = rdr["users_flname"].ToString();
                }
            }

            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
    }
ASKER CERTIFIED SOLUTION
Member_6283346

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 31 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 31 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros