CloudyKooper
CloudyKooper

Reputation: 717

How can I change my connection string to point to SQL Server instead of SQLEXPRESS?

created a project with Web Developer Express 2012 using SQLEXPRESS as the database. I’ve deployed to a shared hosting site and I’m trying to use the connection string provided to me. I was given this:

 Data Source=tcp:TheDatabase.com;Initial Catalog=TheNameOfTheDatabase;User      ID=Username;Password=******;Integrated Security=False; 

Here is how I’m using it:

 <connectionStrings>
   <add name="ApplicationServices"
    connectionString="Data Source=. TheDatabase.com;Initial Catalog= TheNameOfTheDatabase;User ID=Username;Password=******;Integrated Security=False; ;User Instance=true"
    providerName="System.Data.SqlClient" />

I get this error message:

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)

All the research I did points to my connection string trying to access an instance of SQLEXPRESS only I don’t see any where in my string where this is happening. How do I make it point to SQL Server instead of SQLEXPRESS?

Is there somewhere else in web.config that may need changing?

I know this would be easy to fix if I could use IIS to manage the database but my ISP is blocking port 1433 and I can’t connect directly to the site’s database. Very frustrating.

UPDATE" I think my problem is in the Computername/Instance section of the string. Can someone please tell me which part of my string would be the computername and the server instance? On my local machine it is MyPcName/SQLEXPRESS or .\SQLEXPRESS.

UPDATE: Ok got an update from the winhost forum. I shouldn't be using the server_name/Instance_name anyway so I am at a lost.

Upvotes: 0

Views: 4974

Answers (1)

CloudyKooper
CloudyKooper

Reputation: 717

So my project was using the default database (SQL Express) even though I didn’t have a connection string pointing to it. The EF uses convention to attach the default database if you don’t specify by using a constructor like this:

public class BloggingContext : DbContext

{

public BloggingContext()

    : base("BloggingDatabase")

{

}

}

Then this:

 <configuration>

   <connectionStrings>

 <add name="BloggingCompactDatabase"

     providerName="System.Data.SqlServerCe.4.0"

     connectionString="Data Source=Blogging.sdf"/>

 </connectionStrings>

</configuration>

I found it all here… http://msdn.microsoft.com/en-us/data/jj592674.aspx.

Upvotes: 1

Related Questions