Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2008 MySql update using VB

$
0
0
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


Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>