Can't connect to Microsoft SQL Server 2012 Express with Visual Studio

1.2k views Asked by At

I'm new to Visual Studio and SQL Server Express, so I'm sorry of my lack of knowledge.

I have tried to connect in two ways and none of them works. I first wrote a <connectionStrings> element in web.config file.

<connectionStrings>
    <add name="testDB" 
         connectionString=" Data Source=(my computer name)\SQLEXPRESS;Initial Catalog=Factory;Integrated Security=True"  
         providerName="System.Data.SqlClient" />
</connectionStrings>

Which I then wanted to use in a SqlDataSource, and set data connection.

But I get this message:

Database schema could not be retrieved for this connection. Please make sure the connection settings are correct and that the database is online.

Could not load file or assembly ' Microsoft.SqlServer.Management.Sdk.Sfc, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or none of its dependencies.

Even if I try to connect by the Server Explorer(add connection, then (my computer name)\EXPRESS) I get the the same message. But I do find all the tabels, and the connection test works fine.

I've reinstalled SQL Server 2012 Express and SQL Server 2012 Express Management Studio twice.

2

There are 2 answers

0
Rahul Tripathi On

First there is no Visual Studio 2014.

Second you need to download the ENU\x64\SharedManagementObjects.msi for X64 OS to resolve the error

Could not load file or assembly ' Microsoft.SqlServer.Management.Sdk.Sfc, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or none of its dependencies

The problem seems to be that the system cannot locate the right assembly ie, the SQL Server SDK.

0
man_luck On

The error says that the connection settings may be incorrect. You can get the correct sonnection string by dooing the following:

1) Goto View > Server Explorer 2) click data Connections > right click 'Add Connections' and then connect to the server. 3) test the connection and save. This will add your server to server explorer. 4) Click on the just added server in Server Explorer and view properties. 5) Copy the connection string and put it in your web config file. enter image description here