Sql server Visual Studio 2012中的密码验证-使用BindingSource和SQL数据库
我需要帮助。需要进行密码验证,但不知道为什么它不起作用。有人能告诉我我的代码缺失了什么,或者我的思维方式到底出了什么问题吗?我将它连接到dataset2,其中是名为Users2的表。表由两列组成:“用户名”和“密码”。Users2BiningSource.Find应返回当前查询所在索引的值。返回值总是-1,我猜这意味着找不到(false)。我正在使用MicrosoftVisualStudio2012和SQLServer2008SP3,都在Windows7上。谢谢你的时间和帮助Sql server Visual Studio 2012中的密码验证-使用BindingSource和SQL数据库,sql-server,vb.net,visual-studio-2010,data-binding,passwords,Sql Server,Vb.net,Visual Studio 2010,Data Binding,Passwords,我需要帮助。需要进行密码验证,但不知道为什么它不起作用。有人能告诉我我的代码缺失了什么,或者我的思维方式到底出了什么问题吗?我将它连接到dataset2,其中是名为Users2的表。表由两列组成:“用户名”和“密码”。Users2BiningSource.Find应返回当前查询所在索引的值。返回值总是-1,我猜这意味着找不到(false)。我正在使用MicrosoftVisualStudio2012和SQLServer2008SP3,都在Windows7上。谢谢你的时间和帮助 Imports H
Imports Hotel_Booking_System.DataSet2TableAdapters
Public Class Logging
Public Sub check_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Check_Details()
End Sub
Private Sub Quit_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Public Sub Logging_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Users2TableAdapter.Fill(Me.DataSet2.Users2)
'TODO: This line of code loads data into the 'DataSet2.Users2' table. You can move, or remove it, as needed.
End Sub
Public Sub Check_Details()
Me.Users2BindingSource.AddNew()
Dim Usrnm As String = ""
Usrnm = txtUsername.Text
Dim Pswrd As String = ""
Pswrd = txtPassword.Text
Dim Found As Integer
Found = Users2BindingSource.Find("Username", Usrnm)
Dim Found2 As Integer
Found2 = Users2BindingSource.Find("Password", Pswrd)
If Found >= 0 And Found2 >= 0 And Usrnm = "Admin" Then
Me.Hide()
Booking.Show()
ElseIf Found >= 0 And Found2 >= 0 Then
Me.Hide()
Rooms.Show()
Else
MsgBox("Wrong username or password. Please try again", MsgBoxStyle.DefaultButton1, "SOMETHING WENT WRONG")
End If
Label1.Text = Found 'checking the value of found
Label2.Text = Found2 ' checking the value of found2
End Sub
End Class
希望您在执行比较之前对密码进行哈希运算!我想这不是问题。