Link to home
Start Free TrialLog in
Avatar of moraleskp
moraleskp

asked on

Visual Studio 2005 VB.Net Variable Values Showing in Hex

I developing a windows project in visual studio 2005.  I noticed some code is not getting the right results.  In the following code sample,  If Not IsNothing(ID) Then, is always true.  I checked the Value of ID and it was &H0.

How can I fix this?  Thanks in advance
Public Sub Login(ByVal UserName As String, ByVal Password As String, ByVal RememberMe As Boolean)
        Dim ID As Integer
        ID = clsDatabase.GetReaderSingleValue("SELECT ID FROM tblUsers WHERE Username = '" & UserName & "' AND Password = '" & Password & "'", CommandType.Text)
        If Not IsNothing(ID) Then
            GetUserByID(ID)
            Authenticated = True
        End If
    End Sub

Open in new window

Avatar of JackOfPH
JackOfPH
Flag of Philippines image

Try this approach:




Public Sub Login(ByVal UserName As String, ByVal Password As String, ByVal RememberMe As Boolean)
        Dim ID As Integer
        ID = clsDatabase.GetReaderSingleValue("SELECT ID FROM tblUsers WHERE Username = '" & UserName & "' AND Password = '" & Password & "'", CommandType.Text)
        If Not ID is noting Then
            GetUserByID(ID)
            Authenticated = True
        End If
    End Sub

Open in new window

opps, typing error, It should be ...

If Not ID is nothing Then

so the code should be like this



Public Sub Login(ByVal UserName As String, ByVal Password As String, ByVal RememberMe As Boolean)
        Dim ID As Integer
        ID = clsDatabase.GetReaderSingleValue("SELECT ID FROM tblUsers WHERE Username = '" & UserName & "' AND Password = '" & Password & "'", CommandType.Text)
        If Not ID is nothing Then
            GetUserByID(ID)
            Authenticated = True
        End If
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of moraleskp
moraleskp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial