다음 사람이 나를 도와 줄 수 있습니까?MySQL 데이터베이스를 사용하는 VB.NET 로그인
dbhr이라는 데이터베이스를 만들고이 테이블에 VARCHAR 데이터 형식을 갖는 'username'과 'password'라는 두 개의 필드가있는 user라는 사용자가 있습니다. 두 개의 텍스트 상자 (tbxUsername, tbxPassword)와 확인 버튼이있는 로그인 양식이 있습니다. 데이터베이스를 연결하여 사용자 이름과 암호를 인증했습니다. 그러나 그것은 항상 나에게 틀린 암호 메시지를 준다. 내가 어디가 잘못되었는지 모르겠다. 도와주세요.
나는 사전에 MySQL의 워크 벤치 6.1감사를 사용합니다.
다음은 VB.NET 로그인 버튼 코드입니다.
Imports MySql.Data.MySqlClient
Public Class Login
Dim mydbcon As MySqlConnection
Dim COMMAND As MySqlCommand
' TODO: Insert code to perform custom authentication using the provided username and password
' (See http://go.microsoft.com/fwlink/?LinkId=35339).
' The custom principal can then be attached to the current thread's principal as follows:
' My.User.CurrentPrincipal = CustomPrincipal
' where CustomPrincipal is the IPrincipal implementation used to perform authentication.
' Subsequently, My.User will return identity information encapsulated in the CustomPrincipal object
' such as the username, display name, etc.
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
mydbcon = New MySqlConnection
mydbcon.ConnectionString = "server=localhost;userid=root;password=rootword;database=hrdb"
Dim reader As MySqlDataReader
Try
mydbcon.Open()
Dim Query As String
Query = "select * from user where username= ' " & tbxUsername.Text & "' and password= ' " & tbxPassword.Text & "' "
COMMAND = New MySqlCommand(Query, mydbcon)
reader = COMMAND.ExecuteReader
Dim count As Integer
count = 0
While reader.Read
count = count + 1
End While
If count = 1 Then
MessageBox.Show("Username and password are correct")
ElseIf count > 1 Then
MessageBox.Show("Username and password are duplicate")
Else
MessageBox.Show("Username and password are wrong")
End If
mydbcon.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
mydbcon.Dispose()
End Try
End Sub
데이터베이스 테이블 레코드 및 데이터 유형을 보려면 다음 링크를 클릭하십시오.
클릭 here!
일부 다운로드 사이트에 대한 링크를 제공하는 대신이 게시물에 버튼 코드를 삽입하는 것이 어떻습니까? – Mych
버튼 코드가 추가되었습니다. 나는 또한 스크린 샷을 첨부하는 이유는 db 설정을 제공했다. – user3765415
OK ... 이제 어떤 메시지를 항상 받으시겠습니까? BTW ... 암호화되지 않은 비밀 번호를 저장하고있는 것들의 외모에 의해 이것은 당신의 의도입니까? – Mych