locked
SQL ServerSession Mode RRS feed

  • Question

  • User343984601 posted

    Hi, I created custom database to valdiate the user login, no i am trying to create  the session for each user.

    i am trying to use the SQL server session mode, used aspnet_regsql cmd with persistant mode to add two tables (Aspnet TempSession and TempApplication) to the sql server databse and tables are created  automatically. here is the sql connection string

    <sessionState mode="SQLServer"  sqlConnectionString ="Data Source=KENETICS-PC-011\SQLEXPRESS; Integrated Security=SSPI; Initial Catalog=LoginDetails Trusted_Connection=yes"/>

    now i need to conncet with the string that is to create the session after i login, How to use serializable code for this?

    the codebehind shown below for login validation

    public void LoginButton_Click(object sender, EventArgs e)

    {

    if(IsPostBack)

    {

    string connectionString = "Data Source=KENETICS-PC-011\\SQLEXPRESS;Initial Catalog=LoginDetails;User ID=sa;Password=password ";

    SqlConnection con = new SqlConnection (connectionString);

    SqlCommand sd = new SqlCommand("SELECT OfficerID, Password FROM SecureUser WHERE OfficerID = @OfficerID AND Password = @Password", con);

    sd.Parameters.Add("@OfficerID", SqlDbType.NVarChar).Value = tOfficerID.Text;

    sd.Parameters.Add("@Password", SqlDbType.NVarChar).Value = tPassword.Text;

    //String OfficerID = OfficerID.ToString();

    con.Open();

    //Executing using Data Reader

    SqlDataReader r = sd.ExecuteReader();

    if(r.Read())

    {

    lblOfficerID.Text = r["OfficerID"].ToString();

    lblPassword.Text = r["Password"].ToString();

    Response.Redirect("Client\\Report.aspx", true

    );

    }

    else

    {

    InvalidCredentialsMessage.Visible =true;

    }

    r.Close();

    con.Close();

    }

    }

    Please suggest me some solution,

    Thanks

    Sunday, June 12, 2011 11:48 PM

Answers

  • User-269404413 posted

    Mano,

    Here is your need

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 13, 2011 2:23 AM
  • User-578657687 posted

    Hi,

    now i need to conncet with the string that is to create the session after i login, How to use serializable code for this?

    You means that you need to use the code with being serialized. If I don't misunderstanding your requirement, i sugguest you to refer to the links below about serialization and deserialization, I think these tutorials don't only help you to troubleshoot you current issue but also make you benefit when you meet relevant issues of serilization and deserialization in the future:

    http://msdn.microsoft.com/en-us/library/7ay27kt9(v=VS.80).aspx

    http://www.codeproject.com/KB/cs/SerAndDeserialization.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 16, 2011 3:13 AM

All replies