Hi
@KerryZY
first this is an English spoken/written forum, it would be nice if you could write your question in English.
second - my translator said - you want to implement a Form and want to get some information from this SQL Server...
For example you could use this tutorial for connecting your application to SQL Server and grep those information:
https://www.c-sharpcorner.com/UploadFile/5d065a/tutorial-1sql-server-database-connection-in-window-form/
If this is not your plan, then tell us more details about your question/problem.
I don't know you, your knowledge and experience, and regarding your initial text, "just" described the goals you want to achieve... I don't know how much you already have finished, so a good starting point is to connect to the SQL Server; this is where the tutorial is starting, and that's the reason I posted the link.
If you are looking for more details on how to write that function querying data from that SQL Server after the connection is established, then Jiales' answer might be more appropriate.
Hi
@KerryZY
, Welcome to Microsoft Q&A.
Please refer to the same question I replied in Stack overflow.
Simple login and verification
Edit:
private void Button1_Click(object sender, EventArgs e)
//Personal test database
string myconn = "your conn";
SqlConnection conn = new SqlConnection(myconn);
string sql= $"select * from Test.dbo.demoAccount where userid=@UserId";
conn.Open();
SqlCommand sqlCommand = new SqlCommand(sql, conn);
sqlCommand.Parameters.Add("@UserId", SqlDbType.VarChar, 8).Value = AccountTb.Text.Trim();
SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
if (sqlDataReader.HasRows) //Satisfy the user name , enter the next interface
MessageBox.Show("There is this person.");
MessageBox.Show("There is no such person");
conn.Close();
catch (Exception o)
MessageBox.Show(o.ToString());
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.