1

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?

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
sec_goat
  • 169
  • 1
  • 1
  • 13
  • I've just uploaded my asp.net website (not MVC) successfully in host gator with the help of their experts. My problems was the same as yours due to the connection string. Try to change like belows on the Data Source statement: ___ Data Source = localhost ___ Good luck –  May 13 '15 at 16:57

1 Answers1

2

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.

Greg Askew
  • 34,339
  • 3
  • 52
  • 81
  • 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 http://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 03 '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 03 '13 at 17:09
  • Oh I see, `server=tcp:servername` http://weblogs.asp.net/jgalloway/archive/2007/02/24/sql-force-the-protocol-tcp-named-pipes-etc-in-your-connection-string.aspx – TankorSmash Feb 03 '13 at 17:26