[Original] "connectionstring property has not been initialized" SOLUTION

Source: Internet
Author: User

Now, my friends who are a little familiar with Asp.net are used to writing database connection configurations to the Web. config. the configuration in the database in config is as follows:

1 <deleetask>
2 <add key = "connstring" value = "User ID = sa; Password = sasasa; Data Source = (local); initial catalog = 51 aspx"/>
3 </appsettings>

Vs built-in SQL:

<Add key = "sqlcon" value = "Data Source =. \ sqlexpress; attachdbfilename = | datadirectory | \ webzone. MDF; Integrated Security = true; user instance = true"/>
. CS File Usage:

String strconn = configurationmanager. receivettings ["connstring"];

To read, it is worth noting that: this is the read method of ASP. net2.0, in 1.1 is

String strconn = configurationsettings. receivettings ["connstring"];

Many friends may have encountered the prompt "connectionstring attribute has not been initialized". The root cause is that the key value cannot be read. The solution is to correct connstring.

Today, I also encountered the prompt "connectionstring property has not been initialized", and I cannot read the key value in Web. config.

The final reason is that I have established the http: // localhost/test virtual directory. By default, the web in the site http: // localhost is read. config value, which does not have this key at all. Set test as a site (re-create a site to test or point http: // locanhost to test, I hope you can wake up and avoid detours!

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.