如何在c#中创建sql server登录 [英] How to create sql server login in c#

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

问题描述

我正在尝试在wpf中创建一个sql server登录,这些是我遵循的步骤:



1)我使用默认身份验证进行连接Windows身份验证。



2)在应用程序中有一个窗口可以创建sql server登录。在提交按钮上,它创建登录并从文本框中获取用户名和登录密码。



3)我的代码在创建登录后更改连接字符串(综合安全=假)。这意味着我只能使用凭据或sql server身份验证登录。



在我的应用程序中,如果我尝试登录它将无法连接,因为我需要更改或更改登录密码。我在我的wpf应用程序中写了一个更改查询,我仍然无法登录。



然后我不得不去2 sql管理工作室改变我的登录并重新尝试在我的wpf应用程序中,它可以工作。



我知道这听起来有点令人困惑但应用程序就像sql management studio,你需要连接到服务器首先,你可以做任何事情。



请问,有什么解决办法吗?

Hi, I am trying to create an sql server login in wpf and these are the steps I follow:

1) I connect using the default authentication which is Windows auth.

2) In the app there is a window that creates sql server login. On the submit button, it creates the login and gets the username and the login password from the textbox.

3) My code changes the connection string after creating the login(integrated security=false). Which means I can only login with credentials or sql server authentication.

In my app, If I try to login it won't connect because I need to alter or change the login password. I wrote an alter query in my wpf app and I couldn't still login.

Then I had to go 2 sql management studio to alter my login and tried it again in my wpf app, then it works.

I know this might sound a little bit confusing but the app works like sql management studio where you need to connect to a server first before you can do anything.

Please, is there any solution to this?

推荐答案

如果你有MSDN的本地副本

使用SQL语句创建登录

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html /eb737149-7c92-4552-946b-91085d8b1b01.htm

使用SMO创建登录

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9。 en / smo9mref / html / b327d041-e7c3-6396-8a72-200e9507f97b.htm



在线MSDN

使用SQL语句创建登录

http://msdn.microsoft.com/en-us/library/ms189751.aspx

使用SMO创建登录

http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.login.create.aspx
If you ve local copy of MSDN
Create Login using SQL statement
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/eb737149-7c92-4552-946b-91085d8b1b01.htm
Create Login using SMO
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/smo9mref/html/b327d041-e7c3-6396-8a72-200e9507f97b.htm

Online MSDN
Create Login using SQL statement
http://msdn.microsoft.com/en-us/library/ms189751.aspx
Create Login using SMO
http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.login.create.aspx


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

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