新服务器上的Windows身份验证登录失败 [英] login fail for windows authentication on a new server
问题描述
亲爱的程序员,
我已经备份了sql数据库并在另一台计算机上还原了.现在,当我尝试使用C#以编程方式登录到该计算机时,出现错误:用户新计算机名"的登录失败".
我正在使用Windows身份验证,并且我的连接字符串如下所示:
数据源=.\\ sqlexpress;初始目录="office_会话";集成安全性= True
当我尝试Visual Studio时->服务器资源管理器->连接到数据库向导
一切正常.
谢谢您的时间
您是否尝试在SQL Management Studio中进行连接?并且您已经检查过sql配置了吗?
为了知道什么是连接字符串,请创建一个文本文件并将其扩展名更改为udl,例如:ConnectionString.udl,然后单击它完成设置测试后,您将看到一个对话框,现在在进行设置
连接,然后单击确定
现在,右键单击ConnectionString.udl文件并使用记事本打开它,您将在 ^ ]告诉您使用当前Windows帐户凭据进行身份验证.您必须更改SQL Express的某些安全设置.
而且,将程序作为服务运行或在Visual Studio下运行是不一样的.
Dear programmer,
I have backuped my sql database and restored on another computer. Now when I try to login to it programatically using C# I get error: "Login failed for user ''new computer name''".
I am using windows authentication and my connection string looks like this:
Data Source=.\\sqlexpress;Initial Catalog="office_ session";Integrated Security=True
when I try Visual studio -> server explorer -> connect to a database wizard
everything works fine.
Thank you for your time
did you try to connect it in SQL Management Studio? And did you already check your sql configuration?
In order to know what is the connection string create a text file and change the extension of it to udl eg:ConnectionString.udl and click on it you will see a dialog now do the settings once you have done the settings test the
connection and then click on OK
Now right click the ConnectionString.udl file and open it with notepad you will get the connection string
Integrated Security
in the connection string[^] tell to use the current Windows account credentials for authentication. You have to change some security settings for SQL Express.
And running you program as a service or under Visual Studio is not the same.
这篇关于新服务器上的Windows身份验证登录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!