Configure data sources for ASP. NET 2.0

Source: Internet
Author: User

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:

  1. 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.
  2. 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.
  3. 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.

  4. 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 >

  5. 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.

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.