Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 connectionString question

I'm trying to connect to my SQL Server 2008 database with ASP.NET MVC 3. Here is my connection string:

  <connectionStrings>
    <add name="AppConnectionString"
         connectionString="Data Source=(local);Initial Catalog=DatabaseName;User Id=UserName;Password=PassWord;"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

Any idea of what's wrong?

When I try to query something in my DbContext I get this exception:

  • $exception {"The provider did not return a ProviderManifestToken string."} System.Exception {System.Data.ProviderIncompatibleException}

  • InnerException {"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"} System.Exception {System.Data.SqlClient.SqlException}

Could someone help me please?

Thanks

like image 996
Tommy B. Avatar asked Feb 15 '11 15:02

Tommy B.


People also ask

How do I find the ConnectionString in SQL Server?

Right-click on your connection and select "Properties". You will get the Properties window for your connection. Find the "Connection String" property and select the "connection string". So now your connection string is in your hands; you can use it anywhere you want.

Where do I put ConnectionString in web config?

config file in the Views folder.) Find the <connectionStrings> element: Add the following connection string to the <connectionStrings> element in the Web. config file.

Which is the ConnectionString property?

The ConnectionString property can be set only when the connection is closed. Many of the connection string values have corresponding read-only properties. When the connection string is set, these properties are updated, except when an error is detected. In this case, none of the properties are updated.


2 Answers

First check if your mssqlserver services are running fine. Just run net start mssqlserver in your command prompt.

Then try changing the connection string Data Source=(local) to Data Source=.

All the above is assuming that you have sql server installed in your local machine.

like image 130
Sachin Shanbhag Avatar answered Sep 29 '22 07:09

Sachin Shanbhag


That error means that either the name of your Data Source in your connectionstring is wrong or that your sql server is not configured to allow remote connections : see here how to fix it.

like image 36
Sem Vanmeenen Avatar answered Sep 29 '22 06:09

Sem Vanmeenen