Does Godaddy support database connections to App_Data mdf databases?

↘锁芯ラ 提交于 2019-12-13 08:35:47

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/38555321/does-godaddy-support-database-connections-to-app-data-mdf-databases

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!