Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I have urgent requirement to store session variable in sql database.
Please someone help me. I am unknown about this concept.
Thanks & Regards,
Atul Sharma
Posted
Comments
Nirav Prabtani 12-Jul-13 3:42am    
can you describe more???
maneavnash 12-Jul-13 3:44am    
you mean store session value in sql database ....????
AtulOmSharma 12-Jul-13 5:05am    
Ya i mean to store session values in database rather than web server.

First understand the what is session state and go ahead with your requirements...

Exploring Session in ASP.NET[^]


Understanding Session Management Techniques in ASP.NET[^]

http://asp.net-tutorials.com/state/sessions/[^]
 
Share this answer
 
 
Share this answer
 
C#
string admin="admin";
session["data"]=admin;

if(session["data"]!=null)
{

string  sql="insert into table values('"+session["data"].tostring().trim()+"')";

sqlconnection con=new sqlconnection(connectionstring);

con.open();

sqlcommand com=new sqlcommand(sql,con);

com.ExecuteNonQuery();

con.close();
}
 
Share this answer
 
svsdfsd
 
Share this answer
 
Comments
OriginalGriff 20-Nov-15 3:56am    
This is not an answer, and the question is over two years old.
If you continue to post such rubbish, you will be banned from the site.

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