使用 SQL Server 2008

发布于 2024-08-21 16:26:23 字数 410 浏览 4 评论 0原文

我不习惯使用 SQL Server(通常我只使用 Express)。我在windows server 2008,iis7上运行它。

我已将数据库附加到我的 sql 服务器。我在 iis7 中创建了一个网站,但收到此错误消息。

无法打开登录请求的数据库“Phaeton.mdf”。登录失败。 用户“NT AUTHORITY\NETWORK SERVICE”登录失败。

我使用的连接字符串

<add key="PhaetonConnectionString" value="Data Source=.;Initial Catalog=Phaeton.mdf;Integrated Security=True"/> 

谢谢

I am not used to work with SQL Server(usually I just use express). I run it on windows server 2008, iis7.

I have attached the database to my sql server. I made a web site in iis7 but I get this error message.

Cannot open database "Phaeton.mdf" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

Connectionstring I use

<add key="PhaetonConnectionString" value="Data Source=.;Initial Catalog=Phaeton.mdf;Integrated Security=True"/> 

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

肥爪爪 2024-08-28 16:26:23

由于您使用的是集成安全性,SQL 连接将使用从 ASP.NET 传递的 Windows 标识。

您可以将安全性更改为混合模式,这将涉及删除集成安全性。或者使用模拟(检查 IIS 和您的 web.config)并授予该用户对数据库的访问权限。

希望有帮助

Since you are using Integrated Security the SQL connection will use the windows identity which is passed from ASP.NET.

You can either change your security to mixed-mode which will involve removing the integrated security. Or use impersonation (check IIS and your web.config) and grant that user access to the database.

Hope that helps

涙—继续流 2024-08-28 16:26:23

您需要在 IIS 中配置应用程序以关闭匿名访问并打开 Windows 身份验证(如果您想使用集成安全性)。

使用 Windows 集成安全性访问 SQL Server

另一种方式,您可以使用带有用户/密码的连接字符串...以及适当的登录名

You need to configure your application in IIS to turn off anonymous access and turn on Windows authentication(If yoy want to use integrated security).

Access SQL Server Using Windows Integrated Security

The other way, you can use a connection string with user/password ... with the appropriate login

她比我温柔 2024-08-28 16:26:23

问题是我尝试附加的数据库是 sql express

Problem was that the database I tried to attach was sql express

烟酉 2024-08-28 16:26:23

问题就在这里:

初始目录=Phaeton.mdf

在 SQL Server Express 中,您可以附加文件名作为本地数据库。这不是它在生产 SQL Server 上的工作方式。在非 Express 版本中,您永久附加一个数据库,这看起来您已经完成了,并且您给它一个逻辑名称,该名称与主文件名。

我猜想,如果文件名是“Phaeton.mdf”,那么您可能会将数据库命名为“Phaeton”。在这种情况下,连接字符串的该部分应该简单地是:

初始目录=辉腾

如果这不是正确的名称,您可以使用以下脚本从服务器获取数据库名称列表:

USE master;
SELECT name FROM sys.databases

The problem is here:

Initial Catalog=Phaeton.mdf

In SQL Server Express, you can attach a filename as a local database. That's not how it works on a production SQL Server. In non-Express versions you attach a database permanently, which it looks like you've already done, and you give it a logical name, which is not the same as the primary file name.

I would guess that if the file name was "Phaeton.mdf" then you probably named the database "Phaeton". In which case that part of the connection string should simply be:

Initial Catalog=Phaeton

If that's not the right name, you can get a list of database names from the server using the following script:

USE master;
SELECT name FROM sys.databases
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文