更新时间:2023-12-06 12:54:46
尝试一下:
Try this:
using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand com = new SqlCommand("SELECT iD, password FROM myTable WHERE userName=@UN", con))
{
con.Parameters.AddWithValue("@UN", userNameTextBox.Text);
using (SqlDataReader reader = com.ExecuteReader())
{
if (reader.Read())
{
int id = (int) reader["iD"];
byte[] pw = (byte[]) reader["password"];
...
}
}
}
}
然后您可以检查您的密码是否匹配,如果可以,请登录.
顺便说一句:不要以文本格式存储密码-这是一个真正的安全漏洞.而是使用哈希函数. 密码存储:操作方法. [
You can then check your password matches and log him in if it does.
BTW: Don''t store your password in text format - it is a real security hole. Instead, use a Hashing function. Password Storage: How to do it.[^]
检查您的SQL语句. if语句或其中的where子句有问题.
Check your SQL statements. There is something wrong with if statement or a where clause in it.
在此处粘贴您的代码...我们将尝试解决您的问题....
paste your code here...we will try to solve your problem....