Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have been working on a C# MVC4 website and trying to publish it to a Host Gator shared Windows hosting account. They are running both MSSQL 2008 and mySql. We have run into some trouble when trying to get the site to work.

First of all we are using the code first approach to database creation with MVC as well as implementing the SimpleMembership that it offers.

If I publish a basic MVC website as created by a Visual Studios 2010 template, the site will load and display pages, as long as it does not attempt to connect to a database.

I have worked with the Host Gator technical support but they are unable to give me a good answer on how to actually connect to the database. And I have tried all manner of conneciton strings, as well as trying to implement SqlServerCe 3.5.

Some of the connection string examples I have tried are as follows:

<configuration>
    <connectionStrings>
        <add connectionString="Server=myServerAddress;Database=myDataBase;ID=myUsername;Password=myPassword;Trusted_Connection=False" name="connectionName" providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>

and this:

 <connectionStrings>
                <add connectionString=Data Source=ServerIPAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword; />
            </connectionStrings>
        </configuration>

But nothing seems to work, we end up with errors all over the place such as:

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)

It all points to connection strings and not being able to connect.

Does any one have any success stories with HostGator and MVC?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I'm guessing they don't provide RDP access. If so, first thing I would do is attempt to ping the sql server, and try to create a system DSN using odbcad32, and verify that the database is accessible independent of the application.

If your database is not the only or default instance on the SQL server, you may need to specify the instance name in the connection string:

server=serverName\instanceName

It's possible to further craft the connection string to specify tcp/ip and the SQL port number:

tcp:servernameorIP\instanceName,1433  

Another technique that may help provide more information is to perform some other tests in your global.asax.cs, independent of the database access that uses the connections tring, such as pinging the sql server, and attempting to establish a simple tcp connection to the SQL server on 1433.

share|improve this answer
    
I ran through several attempts at using an instance name such as \SQLEXPRESS and \SQLSERVER2008 as some had suggested. No dice. HostGator Also has the Sql server listening on the default port. I was able to make a basic sql connection on the index page and it was successful, coupled wiht your answer and this stackoverflow.com/a/11572020/1001978 I was able to conenct to the DB i think, I am now getting a dbo.table does not exist. Thanks! –  sec_goat Feb 3 '13 at 16:14
    
Is that supposed to be a colon after tcp? Instead of server=serverName is it supposed to be tcp:serverName? –  TankorSmash Feb 3 '13 at 17:09
    
Oh I see, server=tcp:servername weblogs.asp.net/jgalloway/archive/2007/02/24/… –  TankorSmash Feb 3 '13 at 17:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.