"附加自动命名的数据库文件*文件名*失败和QUOT的尝试;从ASP.NET开发服务器移动到IIS错误后 [英] "An attempt to attach an auto-named database for file *FileName* failed." error after moving from ASP.NET Dev Server to IIS

查看:199
本文介绍了"附加自动命名的数据库文件*文件名*失败和QUOT的尝试;从ASP.NET开发服务器移动到IIS错误后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.NET项目在App_Data文件夹中的MDF数据库。

My ASP.NET project has an MDF database in App_Data folder.

连接字符串为:

数据   源= \ SQLEX $ P $干燥综合征; AttachDbFilename = | DataDirectory目录| \ MainDatabase.mdf;集成   安全=真;用户实例=真

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MainDatabase.mdf;Integrated Security=True;User Instance=True

它工作得很好,直到我改变了项目参数使用本地IIS Web服务器,而不是Visual Studio开发服务器。

It worked fine until I changed the project parameters to use "Local IIS Web server" instead of "Visual Studio Development Server".

该项目现在产生以下 SQLEXCEPTION

附加自动命名的数据库文件的尝试   C:\ Users \用户管理\文档\ Visual Studio中   2010 \项目\ SL \ SL \ App_Data文件\ MainDatabase.mdf   失败。具有相同名称数据库存在,或指定的文件无法   打开,或它位于UNC共享。

An attempt to attach an auto-named database for file C:\Users\Admin\documents\visual studio 2010\Projects\SL\SL\App_Data\MainDatabase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

如何修改连接字符串,使其与IIS的工作?

How to modify the connection string to make it work with IIS?

推荐答案

由于您使用的是集成安全性,连接必须映射到SQL Server登录用户。当您更改到IIS,你切换用户,它可能不会映射到数据库的登录。你可以通过指定一个用户名和密码,在你的数据库中有效的测试。

Since you are using Integrated Security, the user connecting has to map to a SQL Server login. When you changed to IIS, you switched the user and it may not map to a login in the DB. You could test this by specifying a username and password that are valid in your database.

例如:

数据源= \ SQLEX $ P $干燥综合征; AttachDbFilename = | DataDirectory目录| \ MainDatabase.mdf;用户ID =管理员;密码=密码;用户实例=真

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MainDatabase.mdf;User Id=admin;Password=password;User Instance=True

这篇关于"附加自动命名的数据库文件*文件名*失败和QUOT的尝试;从ASP.NET开发服务器移动到IIS错误后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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