Store Session values in SQL Server

Source: Internet
Author: User

In general, we like to use Session to store our variables. Asp. Net provides the following methods to store Session values:
InProc
State Server
SQL Server
"InProc" indicates that we store the Session value in the same way as traditional ASP, and "State Server" indicates that we use another host to store the Session value. Of course, we can also use SQL Server to store values. This article is dedicated to explaining this method.
Run the InstallSqlState. SQL File
Find the InstallSqlState. SQL file in WinntMicrosoft. Net and execute it in SQL Server. On my machine, it exists in the E: WINNTMicrosoft. NETFrameworkv1.0.2914 directory. This file is provided by Microsoft and contains a wide range of SQL statements, so you can use it with confidence. Is the generated data table.
Modify your web. config file and set the Session mode to SQL Server.
Change the sessionState section of web. config:
<SessionState mode = "SQLServer"
SqlConnectionString = "data source =
WIN2000; userid =
Sa; password = "cookieless =" false "timeout =
"20"/>
Create Asp. Net Web Forms
Next we will build a test ASP.net program. We don't need to talk about it here when we use the Session program. below is my program. This program simply stores a string of data in the Session, and then displays the data in the Label control.
Now all Session variables are stored in the data table, rather than in the memory. You can open the ASPStateTempSessions table to view the Session data.
Delete these databases and tables
If you don't like the data storage method, you can delete the tables and databases. Do not worry that such deletion will affect the database (because you are afraid to delete some data by mistake), because Microsoft also has to provide you with a delete SQL file named UnintallSQLState. SQL. It is placed in the Config directory of. Net like IntallSQLState. SQL.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.