简体   繁体   English

SQL Server 2008 R2无法登录

[英]SQL Server 2008 r2 can't login

I am working on Windows Server 2003 using SQL Server 2008 R2 and the .NET Framework 4. 我正在使用SQL Server 2008 R2和.NET Framework 4的Windows Server 2003上工作。

My problem 我的问题

I can't login to my database from my website although I can login from my Management Studio 尽管可以从Management Studio登录,但无法从网站登录数据库

I created a login named William . 我创建了一个名为William的登录名。

My connection string is 我的连接字符串是

<add name="TestDbConnectionString" 
     connectionString="Data Source=(local);Initial Catalog=RESv5;User Id=William;Password=MYPASSWORD;"
     providerName="System.Data.SqlClient" />

I got this error: 我收到此错误:

Login failed for user 'William' 用户“ William”的登录失败

NOTE: 注意:

The same username and password I use in the Management Studio and I can login. 我在Management Studio中使用相同的用户名和密码,并且可以登录。

Are the website, the SQL Server instance, and SSMS all running on your local machine? 网站,SQL Server实例和SSMS是否都在本地计算机上运行?

If they are not the same machine, then that is probably the source of the problem: "(local)" on a different machine will mean something different than "(local)" on your own personal laptop. 如果它们不是同一台计算机,则可能是问题所在:另一台计算机上的“(本地)”与您个人笔记本电脑上的“(本地)”有所不同。

Try this for the Data Source portion of the name: 对于名称的“数据源”部分,请尝试以下操作:

Data Source=LocalServerName

... where LocalServerName is the name of the server on which the SQL Server instance is running. ...,其中LocalServerName是运行SQL Server实例的服务器的名称。 If the database is on your machine and the website is elsewhere, use the name of your machine for LocalServerName . 如果数据库在您的计算机上,而网站在其他地方,则将计算机的名称用于LocalServerName

ETA: If you have more than one SQL Server instance running and the one you want is NOT named MSSQLSERVER, you would reference it like this: ETA:如果您有多个SQL Server实例在运行,而您想要的实例未命名为MSSQLSERVER,则可以这样引用它:

Data Source=.\SQLEXPRESS

As marc_s points out, if the instance is called MSSQLSERVER, you can use (local) as you are doing, or 正如marc_s指出的,如果该实例名为MSSQLSERVER,则可以在执行操作时使用(local) ,或者

Data Source=.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM