ASP. NET 2.0 provides a large number of providers, master pages, Theme/skin, and other new technologies, all of which require the support of a database. ASP. NET 2.0 adopts SQL express by default. In actual development, we use SQL Server most, because we need to make certain configurations.
The following describes how to use SQL Server 2 k/2k5 in ASP. NET 2.0 to support databases:
- Run the command aspnet_regsql in the command line environment of visuaol Studio 2005. This tool can be used to create or specify a supported database on the specified SQL Server for ASP. NET 2.0. The default name is aspnetdb.
- Next, you need to modify the configuration file by modifying $: Windows \ Microsoft. net \ framework \ v2.0.50727 \ config \ machine. but modify the machine. config file is not a good method. Fortunately, Asp. NET 2.0 provides. config file.
- Open a Web application Program To add the following configuration section: < Connectionstrings >
< Remove Name = "Localsqlserver" />
< Add Name = "Localsqlserver" Connectionstring = "Server = (local); trusted_connection = false; user id = sa; Pwd = 8848; database = aspnetdb" Providername = "System. Data. sqlclient" />
</ Connectionstrings >
First remove it from the machine with remove. the localsqlsever connection configuration defined in config points to the locally installed SQL Express, and then adds a new localsqlserver database connection to the desired SQL Server database.
- Then configure a default provider using localsqlserver data connection in the <system. Web> node, as shown below: < System . Web >
< Membership Defaultprovider = "Sqlmembershipprovider" >
< Providers >
< Add Connectionstringname = "Localsqlserver" Name = "Sqlmembershipprovider" Type = "System. Web. Security. sqlmembershipprovider, system. Web, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a" />
</ Providers >
</ Membership >
</ System. Web >
- In this way, the configuration file is OK. You can click ASP. Net configuration under the web site menu in vs to test whether the configuration is successful.