Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. retrieve data from Database based on SessionID and populating the textboxes.. [modified]

retrieve data from Database based on SessionID and populating the textboxes.. [modified]

Scheduled Pinned Locked Moved ASP.NET
helpdatabase
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    scar_face
    wrote on last edited by
    #1

    had posted this yesterday but since my ques wasnt proper didnt get many answers..well i want populate my textboxes based on the sessionid with data from database..through that id am populating the textboxes which are the fields in the table..am using datareader's reader method but havin problem..do help..below is the code..

    if (Session["User"] == null) Response.Redirect("Default4.aspx");
    filltrans(System.Convert.ToString(Session["User"]));
    private void filltrans(string User)
    {
    try
    {
    SqlDataReader reader;
    string ConnectionString="...";
    SqlConnection con = new SqlConnection(ConnectionString);
    con.Open();
    SqlCommand cmd = new SqlCommand("View", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter\[\] userdetail = new SqlParameter\[1\];
            userdetail\[0\] = new SqlParameter("@User\_ID", SqlDbType.VarChar,50);
            userdetail\[0\].Value = User.ToString();
            
            reader = cmd.ExecuteReader();
            while(reader.Read())
            {
                txtuser.Text = System.Convert.ToString(reader\["user"\]);
                txtusername.Text = System.Convert.ToString(reader\["user\_new"\]);
                txtmobileno.Text = reader\["MobileNo"\].ToString();
            }
            reader.Close();
        }
        catch (Exception ex)
        {
                  
        }
    }
    

    when i compile and check with breakpoints i found that after the executeReader method its not goin into while loop at all.. thanks..

    scarface

    modified on Tuesday, March 10, 2009 1:10 AM

    A 1 Reply Last reply
    0
    • S scar_face

      had posted this yesterday but since my ques wasnt proper didnt get many answers..well i want populate my textboxes based on the sessionid with data from database..through that id am populating the textboxes which are the fields in the table..am using datareader's reader method but havin problem..do help..below is the code..

      if (Session["User"] == null) Response.Redirect("Default4.aspx");
      filltrans(System.Convert.ToString(Session["User"]));
      private void filltrans(string User)
      {
      try
      {
      SqlDataReader reader;
      string ConnectionString="...";
      SqlConnection con = new SqlConnection(ConnectionString);
      con.Open();
      SqlCommand cmd = new SqlCommand("View", con);

              cmd.CommandType = CommandType.StoredProcedure;
              SqlParameter\[\] userdetail = new SqlParameter\[1\];
              userdetail\[0\] = new SqlParameter("@User\_ID", SqlDbType.VarChar,50);
              userdetail\[0\].Value = User.ToString();
              
              reader = cmd.ExecuteReader();
              while(reader.Read())
              {
                  txtuser.Text = System.Convert.ToString(reader\["user"\]);
                  txtusername.Text = System.Convert.ToString(reader\["user\_new"\]);
                  txtmobileno.Text = reader\["MobileNo"\].ToString();
              }
              reader.Close();
          }
          catch (Exception ex)
          {
                    
          }
      }
      

      when i compile and check with breakpoints i found that after the executeReader method its not goin into while loop at all.. thanks..

      scarface

      modified on Tuesday, March 10, 2009 1:10 AM

      A Offline
      A Offline
      Anurag Gandhi
      wrote on last edited by
      #2

      Check your Stored Procedure. It might be possible your stored procedure is not returning any row for that User.

      Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.

      S 1 Reply Last reply
      0
      • A Anurag Gandhi

        Check your Stored Procedure. It might be possible your stored procedure is not returning any row for that User.

        Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.

        S Offline
        S Offline
        scar_face
        wrote on last edited by
        #3

        had done a mistake in this line userdetail[0] = new SqlParameter("@User_ID", SqlDbType.VarChar,50); had to add cmd.parameters.add..and got the result.. thx for the help..

        scarface

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups