如何使用SQL Server创建用户名和密码 [英] how to create username and password provided that with SQL server
本文介绍了如何使用SQL Server创建用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好我需要帮助用SQL服务器创建用户名和密码我会为用户更改用户名和密码的有效性如何用c#??
hi every body I need help to create username and password with SQL server and I will validity for the user to change the username and password how to do that with c# ??
推荐答案
如果您只是指SQL Server用户而不是Windows身份验证用户,那么您可以使用TSQL命令create user来管理SQL Server上的用户。
那么这是做下面的事情
1.创建调用创建用户(和相关的其他用户TSQL)的代码
2.包装API
3.在用户显示中使用该API,例如C#GUI或Web API。
If and ONLY if you are referring to a SQL Server user and not a Windows authentication user then you can use the TSQL command "create user" to manage the user on SQL Server.
Then it is a matter of doing the following
1. Create the code that calls "create user" (and associated other user TSQL)
2. Wrap in an API
3. Use that API in a user display such as a C# GUI or web API.
您可以按照以下步骤操作这个过程,
1.以设计形式创建两个文本框。
2.在编码中你需要按照以下过程,
You follow the below steps for this process,
1.Create two textboxes in design form.
2.In coding you need to follow the below process,
//Add this namespace
using System.Data.Sqlclient;
oledbconnection con;
oledbdatareader dr;
oledbcommand cmd;
//We need to write the connection string
con=new sqlconnection ("Data Source= ;Integrated Security= ;User Id= ; Pwd= '");
//Now rightclick the button and write the below coding
{
con.Open();
cmd = new SqlCommand("SELECT UserName ,pwd FROM [aaa] WHERE UserName='" + textBox1.Text + "' AND pwd='" + textBox2.Text + "'", con);
SqlDataReader dr = cmd.ExecuteReader();
string userText = textBox1.Text;
string passText = textBox2.Text;
if (dr.Read())
{
this.Hide();
ddd mp = new ddd();
mp.Show();
dr.Close();
con.Close();
}
}
如果您按照上述步骤操作,您将获得完美的输出。
If you are following the above steps you will get the output perfectly.
这篇关于如何使用SQL Server创建用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文