The following code gives me the error of "Object reference not set to an instance of an object" and i cannot figure out why or where the error is coming from. Any help would be appreciated.
Code:
Imports MySql.Data
Imports MySql.Data.MySqlClient
Module LoginDBHandler
Dim strQuery As String = ""
Dim SQLCmd As MySqlCommand
Dim dbCon As MySqlConnection
Dim ServIPadd As String = "LocalHost"
Dim ServPass As String = "Password"
Public Sub accGrant(ByVal username)
Try
dbCon = New MySqlConnection("Server = " & ServIPadd & ";Database=bulhler;Uid = app; Pwd = " & ServPass & "")
dbCon.Open()
Try
strQuery = "UPDATE empusers" & _
"SET logattemps = 0, lastlog = NOW() " & _
"WHERE empusername = '" & username & "'"
SQLCmd.Connection = dbCon
SQLCmd.CommandText = strQuery
SQLCmd.ExecuteNonQuery()
dbCon.Close()
SQLCmd.Dispose()
Catch ex As Exception
MsgBox("Failure to communicate" & vbCrLf & ex.Message)
End Try
Catch ex As Exception
MsgBox("Failure to communicate" & vbCrLf & ex.Message)
End Try
End Sub
End Module