Alternative solution to "connectionstring attribute not initialized"
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>
Use in. CS files
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 created a virtual directory, and the site is read by default. In the Web. config value, there is no such key, set test as a site (re-establish a site to point to this directory or point the site to this directory) OK