sql server登录c# [英] sql server login in c#

查看:82
本文介绍了sql server登录c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我真的很难找出sql server登录这个恼人的问题。当我尝试在我的wpf应用程序中创建登录时,它可以工作但我不能使用用户名和密码通过我的应用程序中的sql server身份验证进行身份验证。我已经禁用了CHECK_POLICY,CHECK_EXPIRATION,MUST_CHANGE选项,我仍然无法登录。我试图通过sqlcommand对象改变登录,它仍然是相同的。然后我去了我的sql管理工作室并更改了我的登录密码,我尝试连接我的wpf应用程序,这次它正常工作。这里的问题是,我希望我的wpf应用程序能够执行alter语句,因为并非所有应用程序用户都有管理工作室,或者他们应该只允许下载sql server而不需要管理工作室,这是从内部完成的wpf app。拜托,伙计们,我需要你的帮助,真的很紧急。谢谢

Hi everyone, I am really finding it hard to figure out this annoying issue with sql server logins. When I try to create a login in my wpf app, it works but I cannot use the username and password to authenticate via sql server authentication in my app. I have disabled the CHECK_POLICY, CHECK_EXPIRATION, MUST_CHANGE options yet, I can't still login. I tried to alter the login via sqlcommand object and it still the same. Then I went to my sql management studio and alter my login password and I tried to connect in my wpf app, and it works this time. The issue here is that, I want my wpf app to be able to do the alter statement because not all app users will have the management studio or they should only be allowed to download the sql server without the management studio which is done internally from the wpf app. Please guys, I need your help, its really urgent. Thanks

推荐答案

检查你的连接字符串。

尝试使用Server Explorer窗格在VS中建立连接:

1)打开服务器资源管理器。

2)右键单击数据连接并选择添加连接

3)在随后出现的对话框中,选择您的数据源,和数据库,指定安全信息,然后按测试连接按钮。

4)当连接工作时,按确定

5)突出显示您的数据库在服务器资源管理器窗格中,查看属性窗格。将显示连接字符串的工作示例,您可以将其复制并粘贴到您的应用程序或配置文件中。
Check your connection string.
Try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource, and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) Highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.


更改密码时应该没有任何问题,但您首先需要建立连接以更改密码。根据您的描述,您使用的密码在更改之前无效。



连接后,任何经过SQL Server身份验证的登录都可以使用ALTER USER命令更改自己的密码。但是如果你需要更改另一个用户密码,那么你需要具有ALTER ANY LOGIN权限(或者是一个sysdamin)。
There shouldn't be any problems when changing password but you first need to establish a connection in order to change the password. Based on your description, the password you used was invalid until you changed it.

Once connected any SQL Server authenticated login can change it's own password using ALTER USER command. But if you need to change another users password, then you need to have ALTER ANY LOGIN privilege (or be a sysdamin).


我创建了一个控制台应用程序并对其进行了测试,它确实有效。我认为它是连接字符串
I created a console app and tested it, and it works. I think its froum the connection string


这篇关于sql server登录c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆