Under normal circumstances, we like to use session to store our variables. ASP.NET provides some of the following methods to save the value of the session:
Inproc
State Server
SQL Server
"Inproc" means that we use traditional ASP's way to store the value of the session, and "State Server" means using another host to store the value of the session. Of course, we can also use SQL Server to save values, our article is specifically used to explain this method.
Run installsqlstate.sql file
First, you need to find the installsqlstate.sql file in WinNT / Microsoft.net, then execute it in SQL Server. In my machine, it exists in the E: /Winnt/Microsoft.Net/framework/v1.0.2914/ directory. This file is Microsoft's own, with a full SQL statement, everyone is safe to use. The following figure is the generated data sheet.
Modify your web.config file, specify the mode for SQL Server
Change the sessionState section of Web.Config:
SqlConnectionstring = "data source = Win2000; userid = sa; password = "cookieles =" false "timeout = "20" /> Create ASP.NET Web Forms Let's establish a test ASP.NET program, using the session program, you don't have to say more. Here is the screenshot of my program. This program is just a simple storage of a string data in the session, then displaying this data in the Label control. All SESSION variables are now stored in the data table instead of memory. You can open the AspStateTemptionions table to see these session data. Delete these databases and tables If you don't like this data store, it is really unhappy, then you can completely remove these tables and databases. Don't worry about this delete will affect the database (because some data is deleted), because Microsoft also gives you a delete SQL file, named UnintSqlState.sql. It is placed in the .NET's config directory like INTALLSQLSTATE.SQL.