简体   繁体   English

SQL异常 - 用户“UserName $”登录失败

[英]SQL Exception - Login failed for user “UserName$”

I am having an issue with one of my pages that is pulling content from a database which is displayed in <select> tags. 我的一个页面的问题是从<select>标签中显示的数据库中提取内容。 I have seen many others with this issue but haven't seen anyone's have a $ after the user. 我见过很多其他人有这个问题,但没有看到任何人在用户之后有$。 I am not sure why it is adding a $. 我不确定为什么要加$。 I have redone my connection string, .dbml file and have even created a user AD\\INFO4420$ in my database and have given it read and write privileges. 我重做了我的连接字符串,.dbml文件,甚至在我的数据库中创建了一个用户AD \\ INFO4420 $,并赋予它读写权限。 When using Visual Studios I am able to run the page and there is no error but it only occurs when viewing it from the server. 使用Visual Studios时,我能够运行页面并且没有错误,但只有在从服务器查看时才会出现错误。

The Error is as follows: 错误如下:

Login failed for user 'AD\\INFO4420W$'. 用户'AD \\ INFO4420W $'登录失败。

Description: An unhandled exception occurred during the execution of the current web request. 描述:执行当前Web请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code. 请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'AD\\INFO4420W$'. 异常详细信息:System.Data.SqlClient.SqlException:用户'AD \\ INFO4420W $'登录失败。

Connection String in my Web.config: 我的Web.config中的连接字符串:

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Final_Project-20131204200025;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Final_Project-20131204200025.mdf"
      providerName="System.Data.SqlClient" />
    <add name="TowingApp_dbConnectionString" connectionString="Data Source=INFO4420W.ad.uvu.edu;Initial Catalog=TowingApp_db; Integrated Security=true"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

I know the program is using the following as the connection string. 我知道程序使用以下作为连接字符串。 Any time I comment out the following it throws another error. 任何时候我注释掉以下它会引发另一个错误。

<add name="TowingApp_dbConnectionString" connectionString="Data Source=INFO4420W.ad.uvu.edu;Initial Catalog=TowingApp_db; Integrated Security=true"
          providerName="System.Data.SqlClient" />

Any help or direction would be appreciated! 任何帮助或方向将不胜感激!

You're using integrated security Integrated Security=true . 您正在使用集成安全性Integrated Security=true It works locally because your local windows account has access to local SQL Server DB. 它在本地工作,因为您的本地Windows帐户可以访问本地SQL Server数据库。 Perhaps you have to switch to SQL Server authentication with dedicated ID and password. 也许您必须使用专用ID和密码切换到SQL Server身份验证。

In that case instead of Integrated Security=true you would specify 在这种情况下,您将指定而不是Integrated Security=true

User ID=YourUserid;Password=YourPassword;

My guess the ID/Password should be provided to you by the univercity. 我猜大学应该提供ID /密码。 Also to avoid having ID and password in open text either supply them from code or encrypt the connection string. 另外,为了避免在开放文本中使用ID和密码,请从代码中提供它们或加密连接字符串。

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

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