Store session values in SQL Server _mssql

Source: Internet
Author: User
In general, we like to use the session to store our variables. ASP.net provides the following methods for storing the values of the session:
InProc
State Server
SQL Server
"InProc" means that we store the value of the session using the traditional ASP method, and that "state Server" means using another host to store the value of the session. Of course we can also use SQL Server to store values, and this article is dedicated to explaining this approach.
Running InstallSqlState.sql files
First you need to find the InstallSqlState.sql file in Winntmicrosoft.net, and then execute it in SQL Server. In my machine, it exists in the e:winntmicrosoft.netframeworkv1.0.2914 directory. This file is provided by Microsoft itself, which has a full SQL statement, we are assured to use. The following figure is the resulting data table.
Modify your Web.config file to specify the session mode as SQL Server
Change the sessionstate portion of the web.config to:
<sessionstate mode= "SQL Server"
sqlconnectionstring= "Data source=
Win2000;userid=
Sa;password= "cookieless= false" timeout=
"/>"
Create ASP.net Web Forms
The following set up a test asp.net program, using the session program here is needless to say, the following is my program screenshot. This program simply stores a string of data in the session and then displays the data in the label control.
All of the session variables are now stored in the datasheet, not in memory. You can open the ASPStateTempSessions table to view the session data.
Delete these databases and tables
If you don't like the way the data is stored, it's really bad, so you can delete the tables and the database altogether. Don't worry about that. This deletion affects the database (because of the fear of accidentally deleting some data), because Microsoft also has to provide you with a delete SQL file named Unintallsqlstate.sql. It is placed in the. Net config directory as 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.