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";
try
{
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.");
}
else
{
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.