connection-stringapp-data

Does Godaddy support database connections to App_Data mdf databases?


Quite simply, what is the correct connection string to an mdf file database located in the App_Data directory of my asp.net website hosted on Godaddy? Naturally this works offline in my developer environment but causes problems when uploading to Godaddy. Does Godaddy support connecting to databases contained within the App_Data directory? I suspect my problem is the Data Source portion and selecting a SQL Server instance but I'm not sure.

I clear the "LocalSqlServer" connection before adding the actual connection string info first.

<connectionStrings>
    <remove name="LocalSqlServer"/>
    <clear/>

And here's what I've tried with varrying errors:

1.

<add name="LocalSqlServer" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;|DataDirectory|\DatabaseFileName.mdf&quot;;Initial Catalog=&quot;DatabaseFileName&quot;;Integrated Security=True" providerName="System.Data.SqlClient" />

Error: 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)

2.

<add name="LocalSqlServer" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=&quot;|DataDirectory|\DatabaseFileName.mdf&quot;;Initial Catalog=&quot;DatabaseFileName&quot;;Integrated Security=True" providerName="System.Data.SqlClient" />

Error: [SqlException (0x80131904): 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]

3.

<add name="LocalSqlServer" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=DatabaseFileName;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\DatabaseFileName.mdf" />

Error. Same as number 2 above.

Many many thanks for assistance on this!


Solution

  • Not much response on this question, but from my calls with GoDaddy, I'm going to say the answer is No - they do not support databases stored in your local App_Data folder. From experimenting with this problem, I found that to do what I wanted to do, you need to specify two things in the connection string of your web.config file.

    1. DataSource: The sql server database engine. In development, this is commonly set to sqlexpress or localdb.
    2. AttachDbFilename: This is the reference to the mdf database file in App_Data.

    I was able to set my DataSource to an instance of SQL Server on Godaddy, however, when using the AttachDbFilename attribute, I would get a server error saying there was a problem with my AttachDbFilename value.

    GoDaddy support (at least the agents I spoke with) gave conflicting information. The first agent was obviously not confident in what they were talking about but said "it's possible" but claimed because of their statement of support he couldn't help me figure it out. The second agent was more knowledgeable and was actually messaging with (I presume) an actual database tech that basically stated it won't work.

    In the end, I should have realized this was not possible sooner as it's their business model to sell you additional databases once you have used the two they include in the shared hosting plan. It would just be nice if they would say directly on their DB admin page in the Hosting Manager that attaching databases is not allowed... would have saved me time and aggravation.

    If anyone has successfully attached to their App_Data mdf - post your connection string, otherwise I'm marking this as the answer as soon as SO will let me.