Baraka_1989
Member
- Joined
- Mar 8, 2012
- Messages
- 7
- Programming Experience
- Beginner
Hello guys, I'm really stuck! I'm making a login app where there are multi users and the usernames and passwords are stored in a mysql database
but when i implement it, nothing happens, I get no response! Please, HEEEEEEEEEELP
******************************************************************
BELOW ARE THE CODES
******************************************************************
but when i implement it, nothing happens, I get no response! Please, HEEEEEEEEEELP
******************************************************************
BELOW ARE THE CODES
******************************************************************
Imports MySql.Data Imports MySql.Data.MySqlClient Public Class LoginForm Dim dbCon As MySqlConnection Dim strQuery As String Dim sqlCmd As MySqlCommand Dim DR As MySqlDataReader Dim enteredUserName, enteredPassword As String 'a subroutine to check the validity of the user's credentials Public Sub AuthenticateUser() enteredUserName = TXBUserName.Text enteredPassword = TXBPassword.Text Try 'prepare connection and query dbCon = New MySqlConnection("Server=localhost;User id=root;Password=;Database=register") strQuery = "SELECT username,password " & _ "FROM login WHERE username='" & enteredUserName & "' AND password='" & enteredPassword & "'" 'creating the command to launch the query to the database sqlCmd = New MySqlCommand(strQuery, dbCon) 'Open the db and kick off the query dbCon.Open() DR = sqlCmd.ExecuteReader While DR.Read() If enteredUserName = DR.Item("username") And enteredPassword = DR.Item("password") Then ServicesAvailableForm.Show() Me.Hide() Else MsgBox("Wrong username and/or password", MsgBoxStyle.Critical, "ERROR") End If End While 'close the connection in order to allow other users to use the database DR.Close() dbCon.Close() Catch ex As Exception MsgBox("FAILURE TO COMMUNICATE WITH THE DATABASE!" & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Information, "DATABASE CONNECTION STATUS") End Try End Sub Private Sub BTNLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNLogin.Click AuthenticateUser() End Sub End Class
Last edited by a moderator: