我的 ASPNETDB.MDF 无法在生产服务器中工作?
今天,我使用登录控件创建了两个页面 login.aspx 并使用创建用户向导创建了 register.aspx ...
当我在本地计算机中使用生产服务器的连接字符串时,只有当我的数据库 ASPNETDB.MDF 时,站点才能工作存在于我的本地计算机的 APP_Data 文件夹中。
如果我重命名 ASPNETDB.MDF 或从本地计算机 App_Data 中删除 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>
Possible Duplicate:
A network-related or instance-specific error occurred while establishing a connection to SQL Server.
Today i have create two pages login.aspx using LOgin control and register.aspx using Create user wizard ...
when i use connection string of my production server in my local computer then site works only if my database ASPNETDB.MDF is present in APP_Data Folder in my local computer..
if i rename ASPNETDB.MDF or Delete ASPNETDB.MDF from my local compuet App_Data the the following error occurs ...
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.
but
After i publish my webpages ..... and database to my production server .... it produces an 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)
What was the problem actually ... ??
MY PRODUCTION SERVER CONNECTION STRING :
<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>
MY LOCAL SERVER CONNECTION STRING :
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为您需要添加对要放置数据库的目录的访问权限。这些权限必须适用于运行您使用的 asp.net 池的用户。
或者,对于生产服务器和本地服务器,尝试此字符串,只需确保您的数据库具有从 asp.net 运行池帐户访问的正确权限。
这并不取决于您在字符串上写入的内容,而是取决于您如何正确设置数据库。它 100% 工作,所以如果不发挥作用,您将搜索数据库权限、文件和数据库设置。
This is because you need to add access permissions to the directory that you going to put the database. The permissions must be for the user that runs the asp.net pool that you using.
Alternative try this string, for both production and local server and just be sure that your database have the correct permissions for been access from the asp.net running pool account.
This is not depended from what you write on the string but from how you correctly setup the database. Its working 100% so if not play for you search the database permissions, both file and database settings.