Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3694600
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:30:58+00:00 2026-05-19T04:30:58+00:00

I am trying to create a login form on my ASP.NET website. Currently, there’s

  • 0

I am trying to create a login form on my ASP.NET website. Currently, there’s some problem. I am trying to incorporate the functionality such that the logged in user has the previlige to view only his profile. The code on the login page is this:

business.clsprofiles obj = new business.clsprofiles();
        Int32 a = obj.logincheck(TextBox3.Text, TextBox4.Text);
        if (a == -1)
        {
            Label1.Text = "Username/Password incorrect";
        }
        else
        {
            Session["cod"]= a;
            Response.Redirect("profile.aspx");
        }

After logging in, the user is moved to the page where the person can view his profile once logged in. Session is obtaining the value correctly of the logged in person from the login-page and successfully passing it on to the next page. But here on this profile page an error occurs and I think there is problem somewhere in the grid_bind() method below

public void grid_bind()
{
    business.clsprofiles obj = new business.clsprofiles();
    List<business.clsprofilesprp> objprp = new List<business.clsprofilesprp>();
    Int32 z = Convert.ToInt32(Session["cod"]);
    objprp = obj.fnd_profiles(z); //This line of code is passing an integer as required but does not get the desired result from the database
    GridView1.DataSource = objprp;
    GridView1.DataBind();
}

As the error in business logic says, ” invalid attempt to read when no data is present in dr”

public List<clsprofilesprp> fnd_profiles(Int32 id)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("fndpro", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@id", SqlDbType.Int).Value = id;
            SqlDataReader dr = cmd.ExecuteReader();
            List<clsprofilesprp> obj = new List<clsprofilesprp>();
            while(dr.HasRows)
            {
                clsprofilesprp k = new clsprofilesprp();

                k.id = Convert.ToInt32(dr[0]);//Something wrong here?

                k.name = dr[1].ToString();
                k.password = dr[2].ToString();
                k.description = dr[3].ToString();
                k.created = Convert.ToDateTime(dr[4]);
                k.modified = Convert.ToDateTime(dr[5]);
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return obj;
        }lesprp k = new clsprofilesprp();

        k.id = Convert.ToInt32(dr[0]);//Something wrong here?

                k.name = dr[1].ToString();
                k.password = dr[2].ToString();
                k.description = dr[3].ToString();
                k.created = Convert.ToDateTime(dr[4]);
                k.modified = Convert.ToDateTime(dr[5]);
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return obj;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:30:58+00:00Added an answer on May 19, 2026 at 4:30 am

    You have to call DataReader.Read to fetch the result:

    SqlDataReader dr = cmd.ExecuteReader();
    dr.Read();
    // ...
    

    DataReader.Read returns a boolean, so if you have more than 1 result, you can do:

    While (dr.Read())
    {
      // read data for each record here
    }
    

    Moreover, you’re trying to access the dr data when there’s none in this part of the code:

    k.id = Convert.ToInt32(dr[0]);//Something wrong here?
    k.name = dr[1].ToString();
    k.password = dr[2].ToString();
    k.description = dr[3].ToString();
    k.created = Convert.ToDateTime(dr[4]);
    k.modified = Convert.ToDateTime(dr[5])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create two ASP.NET Membership login pages for an ASP.NET website I'm
Context: Asp.Net MVC3 w/Razor I am trying to put a login form on a
I am trying to create a login form. The problem that I am having
I am new to zend. I am trying to create login form using zend
I am trying to create a C# script to login automatically to a website
I am trying to create a secure login for my site, who's form logs
I'm trying to build a simple website with login functionality very similar to the
I'm actually trying to create a login form matching with my database. The form
I'm trying to Create a login form, and registration form. My registration form is
I'm a little new to Django, and I'm trying to create a login form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.