简体   繁体   English

现有用户SQL Server 2012登录失败

[英]Login Failed for existing user SQL Server 2012

Using C# I'm trying to connect to an existing DB in SQL Server 2012, from Visual Studio 2012. I used the Visual Studio wizard to get my connection string, and I told it to use Windows Authentication (what I am using for my SQL DB, hosted locally on my system). 使用C#,我试图从Visual Studio 2012连接到SQL Server 2012中的现有数据库。我使用Visual Studio向导获取我的连接字符串,并告诉它使用Windows身份验证(我在SQL中使用的身份) DB,在我的系统上本地托管)。 This is the error I get: 这是我得到的错误:

Cannot open database "C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQ\DATA
\StockHolesDB.mdf" requested by the login. The Login failed.
Login failed for user '***\***'.

My connection string is "Data Source=(LocalDB)\\\\v11.0;AttachDbFilename=\\"C:\\\\Program Files\\\\Microsoft SQL Server\\\\MSSQL11.MSSQLSERVER\\\\MSSQL\\\\DATA\\\\StockHolesDB.mdf\\";Integrated Security=True;Connect Timeout=30" 我的连接字符串是"Data Source=(LocalDB)\\\\v11.0;AttachDbFilename=\\"C:\\\\Program Files\\\\Microsoft SQL Server\\\\MSSQL11.MSSQLSERVER\\\\MSSQL\\\\DATA\\\\StockHolesDB.mdf\\";Integrated Security=True;Connect Timeout=30"

Looking around online I saw that one of the solutions is to set that user up in the sql server. 在线浏览时,我看到解决方案之一是在sql服务器中设置该用户。 But that user is already set up in the server. 但是,用户服务器已经成立。 A different username, but the same login name. 用户名不同,但登录名相同。 And when I tried to add a new user with the same login name but different username it wouldn't work. 而且,当我尝试添加具有相同登录名但用户名不同的新用户时,它将不起作用。

EDIT: I tried changing the DB name, and that didn't work either. 编辑:我试图更改数据库名称,并且也没有用。

确保已在MSSQL上启用“ SQL Server和Windows身份验证模式”(在服务器上的“安全性”选项卡下,右键单击)

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

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