【问题标题】:MY ASPNETDB.MDF would not work in production server? [duplicate]我的 ASPNETDB.MDF 不能在生产服务器上工作? [复制]
【发布时间】:2011-01-20 08:00:48
【问题描述】:

可能重复:
A network-related or instance-specific error occurred while establishing a connection to SQL Server.

今天我创建了两个页面 login.aspx 使用 LOgin 控件和 register.aspx 使用创建用户向导 ...

当我在本地计算机中使用生产服务器的连接字符串时,只有当我的数据库 ASPNETDB.MDF 存在于本地计算机的 APP_Data 文件夹中时,站点才能工作..

如果我从本地计算机 App_Data 重命名 ASPNETDB.MDF 或删除 ASPNETDB.MDF,则会出现以下错误...

An attempt to attach an auto-named database for file C:\Users\Ashish Dobriyal\Documents\Visual Studio 2008\WebSites\VOLVOO\App_Data\ASPNETDB.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. 

但是

在我将我的网页.....和数据库发布到我的生产服务器之后......它会产生一个错误......

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)

究竟是什么问题……??

我的生产服务器连接字符串:

<connectionStrings>
    <remove name="ConnectionString"/>
        <add name="ConnectionString" connectionString="workstation id=volvobusesindia.mssql.somee.com;packet size=4096;user id=username;pwd=password;data source=dobriyal.mssql.somee.com;persist security info=False;initial catalog=dobriyal" providerName="System.Data.SqlClient"/>
  </connectionStrings>

我的本地服务器连接字符串:

<connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>

【问题讨论】:

  • 请发布您的连接字符串!两者:生产和开发
  • 你一遍又一遍地问基本相同的问题 - 请停止!
  • 我的问题无法解决...
  • 可以解决的。但是一遍又一遍地问这个问题只会让社区感到沮丧。问一次这个问题。如果您还没有找到解决方案,请在您的位置更新您的问题。我们不是你忠实的仆人。

标签: asp.net visual-studio-2008 sql-server-2005 aspnetdb


【解决方案1】:

当我使用我的连接字符串时 我本地计算机中的生产服务器 那么站点仅在我的数据库时才有效 ASPNETDB.MDF 存在于 APP_Data 我本地计算机中的文件夹..

这是因为您需要为要放置数据库的目录添加访问权限。权限必须针对运行您使用的 asp.net 池的用户。

对于生产服务器和本地服务器,也可以尝试使用此字符串,并确保您的数据库具有从 asp.net 运行池帐户访问的正确权限。 这不取决于您在字符串上写入的内容,而是取决于您如何正确设置数据库。它的工作 100% 所以如果你不玩搜索数据库权限,包括文件和数据库设置。

<connectionStrings>    
            <add name="ConnectionString" connectionString="Data Source=localhost;Initial Catalog=dobriyal;Integrated Security=True;" providerName="System.Data.SqlClient" />   
</connectionStrings>   

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-11
    • 1970-01-01
    • 1970-01-01
    • 2016-11-05
    • 2014-06-19
    • 1970-01-01
    • 2021-12-28
    相关资源
    最近更新 更多