我想創建一個登錄表單,其中的密碼字段是區分大小寫的例子,如果我的密碼是「PassWord」,它將只接受關鍵字「PassWord」而不接受「password」或者「密碼」等關鍵字,我希望它的字符敏感的感謝,請幫助我使用數據庫MS ACCESS感謝這裏我是一個新的編程是我的代碼在VB 10中創建一個區分大小寫的登錄表單
Private Sub btnLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLog.Click
Try
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\NIASecurity.accdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT [Username] FROM [Security] WHERE [Username] = @User and Password [email protected] ", con)
cmd.Parameters.AddWithValue("@User", txtUser.Text)
cmd.Parameters.AddWithValue("@Pass", txtPass.Text)
con.Open()
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
If sdr.Read Then
If txtPass.Text = sdr(0) Then
MessageBox.Show("Welcome")
Dim win As New frmAdd
win.MdiParent = frmMDI
win.Show()
Me.Close()
Else
MsgBox("Invalid name or password!")
End If
End If
Catch ex As Exception
MessageBox.Show("Invalid name or password!")
End Try
End Sub
請請不要以純文本存儲您的密碼。使用密碼散列法(bcrypt,PBKDF2,...)如果數據庫遭到破壞,您的用戶不應該擔心在其他地方更改密碼。 – 2014-09-28 07:42:06
這麼做?請? – 2014-09-28 09:10:15