Godaddy是否支持与App_Data mdf数据库的数据库连接? [英] Does Godaddy support database connections to App_Data mdf databases?

查看:108
本文介绍了Godaddy是否支持与App_Data mdf数据库的数据库连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很简单,与Godaddy上我的asp.net网站的App_Data目录中的mdf文件数据库的正确连接字符串是什么?自然,这在我的开发人员环境中可以脱机工作,但是在上传到Godaddy时会引起问题. Godaddy是否支持连接到App_Data目录中包含的数据库?我怀疑我的问题是数据源"部分并选择一个SQL Server实例,但是我不确定.

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.

在先添加实际的连接字符串信息之前,我先清除"LocalSqlServer"连接.

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" />

错误:建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称正确,并且已将SQL Server配置为允许远程连接. (提供者:SQL网络接口,错误:26-指定服务器/实例时出错)

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" />

错误:[SqlException(0x80131904):建立与SQL Server的连接时发生了与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称正确,并且已将SQL Server配置为允许远程连接. (提供者:SQL网络接口,错误:52-无法找到本地数据库运行时安装.验证是否正确安装了SQL Server Express并启用了本地数据库运行时功能.)]

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" />

错误.与上面的数字2相同.

Error. Same as number 2 above.

非常感谢您对此提供的帮助!

Many many thanks for assistance on this!

推荐答案

对此问题的答复不多,但是从我与GoDaddy的通话中,我要说的答案是否"-它们不支持存储在您的数据库中的数据库.本地App_Data文件夹.通过试验此问题,我发现要执行我想做的事情,您需要在web.config文件的连接字符串中指定两件事.

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:sql服务器数据库引擎.在开发中,通常将其设置为sqlexpress或localdb.
  2. AttachDbFilename:这是对App_Data中mdf数据库文件的引用.

我能够将DataSource设置为Godaddy上的SQL Server实例,但是,当使用AttachDbFilename属性时,会出现服务器错误,提示我的AttachDbFilename值存在问题.

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的支持(至少与我交谈过的代理商)提供了相互矛盾的信息.这位第一特工显然对他们在说什么并不自信,但是说有可能",但是由于他们的支持声明而声称他无法帮助我弄清楚这一点.第二个代理更加有知识,实际上正在与(我假设)一个实际的数据库技术进行消息传递,该技术基本上表明它将无法工作.

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.

如果任何人都已成功附加到他们的App_Data mdf,请发布您的连接字符串,否则我会立即将其标记为答案.

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.

这篇关于Godaddy是否支持与App_Data mdf数据库的数据库连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆