Can i store session value in a table with button click. In my code below I want the UserName in table..
Here is the code I’m using:
string cmdstr = "select count(*) from Reg where UserName='" + TextBoxaun.Text + "'";
SqlCommand checkUser = new SqlCommand(cmdstr, con);
int temp = Convert.ToInt32(checkUser.ExecuteScalar().ToString());
if (temp == 1)
{
string cmdstr2 = "select Password from Reg where UserName='" + TextBoxaun.Text + "'";
SqlCommand pass = new SqlCommand(cmdstr2, con);
string password = pass.ExecuteScalar().ToString();
con.Close();
if (password == TextBoxapass.Text)
Session["newapply"] = TextBoxaun.Text;
}
First of all, you need ASP.NET SQL Server Registration Tool
After you create ASPState database, you must change session state mode in web.config like this:
P.S. When you are using SQLServer or StateServer modes, objects must be serializable. For more details see Session-State Modes