Hi there,

I am trying to create a session based on a field from a datareader.

the code I have so far is

string sqlStmt = "Select Member_Username, MemberID from Members where Member_Username='" + UserName.Text + "' and Member_Password='" + PassWord.Text + "'";
SqlConnection sqlConn = new SqlConnection("server=********;");
SqlCommand sqlCmd = new SqlCommand(sqlStmt, sqlConn);
        sqlCmd.Connection.Open();
        SqlDataReader sqlReader = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection);
        Session["username"]=UserName.Text;
        if (sqlReader.Read())
        FormsAuthentication.RedirectFromLoginPage(UserName.Text, true);
        else
            LtlLogin.Text = "Invalid Login";

The session I need to create is the MemberID.

Any ideas?

its simple just
use session id as primary key
and create new table in database
as you want to create
and use sql commamnd insert into table...

Think I lost you there.

I am trying to create the session from a value in that datareader.

(ie) session["memberID"] = SqlReader("MemberID")

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.