Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a login page where i create a session and took a value of memberId from database as
session["_memberid"]=memberId.tostring(); (tell me if this is wrong)
now i think my session will pic a member Id from database.
now i want that integer member Id on some other page detail.aspx
how to retrieve that.?
please help me
Posted

To Make Select Query to retrive your MemberId,
Example:
C#
SqlConnection con=new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=shoping;Integrated Security=True");
        con.Open();
SqlCommand cmd=new SqlCommand("Select memberid from Members Where membername='"+TextBox1.Text+"'",con);
SqlDataReader dr = cmd.ExecuteReader();
      while (dr.Read())
      {
string id=dr.GetValue[0].ToString();
Session["_memberid"]=id;
}
 
Share this answer
 
v2
Comments
[no name] 6-Nov-12 6:21am    
working in entity
It's easy-you just need to typecast the value stored in session 


C#
public partial class ClassA : System.Web.UI.Page
{
    int ID;
    protected void Page_Load(object sender, EventArgs e)
    {
       ID=Convert.toInt32(Session["EmpID"]);
    }
}
 
Share this answer
 
v2
Comments
[no name] 6-Nov-12 6:26am    
not working

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