C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

How to maintain the session in sql server


Posted Date: 16 Jul 2004    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Hema KumarMember Level: Silver    
Rating: 1 out of 5Points: 10



As we know that we can store the session state in the SQL server. Practically This is very simple to use. For Your application if reliability is more important than performance, then SQLServer is a better option compared to InProc and State Server

In this case we can maintain the Application in one server and Session in another server.
You can Find the default stored procedures provided by Dot net it self in the following
Directory. There are two Scripts one for Installing the database and another Uninstalling the
Database

c:\windows\Microsoft.Net\Framework\version\InstallSQLstate.sql

Just Execute the Script in Query analyzer and a new database will be created with the name "ASPState". If you open and see u can't find any tables. Open the database "Tempdb", which contains two tables namely

1. ASPStateTempApplications
2. ASPStateTempSessions

And also it contains some stored procedure for inserting and retrieving the data. Now, all we need to do, as ASP.NET takes care of everything else for us, is modify the web.config so that the ASP.Net application knows it should use SQLServer for session state management.

Consider the following example configuration in web.config file sessionState tag. Change the sqlConnectionString According to your settings.

mode="SQLServer"
sqlConnectionString="data source=localhost;user id=sa;password=HemaKumar"
cookieless="true"
timeout="20" />

Now How Test the application ? Just Create one sample page called "Sample.aspx". In page Load Assign the following statements.

Session("User")="HemaKumar"
session("Company")="Exira Software"

Just run the application Now. It works...........

Happy Programming...

REFERENCE: MSDN Documentation.



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Registry handling
Previous Resource: New features in ASP.NET 2.0
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use