0

I've import my SQL 2005 database to my project and i am trying to connect to the database using the web.config

But I've this error when I add the connectionString to the web.config.

    <add name="strConn" connectionString="Data Source=.\sqlexpress;Initial Catalog=intranet_db;Integrated Security=True"
     providerName="System.Data.SqlClient"/>

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid. Detailed Error Information:

  • Module IIS Web Core
  • Notification Unknown
  • Handler Not yet determined
  • Error Code 0x80070032
  • Config Error The configuration section 'add' cannot be read because it is missing a section declaration
  • Config File \?\C:\Users\user\Documents\Visual Studio 2012\Projects\test\test\web.config
  • Requested URL localhost:64198/
  • Physical Path
  • Logon Method Not yet determined
  • Logon User Not yet determined
  • Request Tracing Directory
    C:\Users\user\Documents\IISExpress\TraceLogFiles\

    Am I doing it wrong? What should I add in the web.config?

Thanks.

2
  • 1
    Can you show us your complete web.config Commented Mar 5, 2014 at 8:08
  • 1
    Could you provide the surrounding code? I cannot see any errors in add tag itself Commented Mar 5, 2014 at 8:08

3 Answers 3

1

Please make sure you put the "add" tag in the correct place. I'm able to reproduce your error when I place it i wrong section. Your web.config file should look like this:

<configuration>
  <connectionStrings>
    <add name="strConn" connectionString="Data Source=.\sqlexpress;Initial Catalog=intranet_db;Integrated Security=True"
     providerName="System.Data.SqlClient"/>
   </connectionStrings>
</configuration>
Sign up to request clarification or add additional context in comments.

Comments

1

it should be something like this

<connectionStrings>
        <add name="connectionString" connectionString="Provider=SQLOLEDB.1;Data Source=dbhostname;Persist Security Info=True;Password='password';User ID='username';Initial Catalog=dbname" />
</connectionStrings>

Comments

0

have a look at http://www.connectionstrings.com/ it has examples of what they should be.

looking at you connection string make sure the instance name ./SqlExpress is correct.

A quick test would be to load sql manager and connect with the ./SqlExpress

Standard Security

Server=myServerAddress;Database=myDataBase;User Id=myUsername; Password=myPassword;

Trusted Connection Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

to give you a better answer would require knowing how you want to connect to the database.

2 Comments

I am trying to connect to localhost sqlexpress and I have changed my .\sqlexpress to (localdb)\v11.0 but still have the same error.
what is your instance name? if it's local and default settings it should be YourPCName/SqlExpress.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.