Solved

Visual Studio 2005 VB.Net Variable Values Showing in Hex

Posted on 2009-05-06
3
257 Views
Last Modified: 2013-11-26
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

0
Comment
Question by:moraleskp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321490
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

0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321497
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

0
 

Accepted Solution

by:
moraleskp earned 0 total points
ID: 24321927
thanks for the reply jack.
The clsDatabase procedure was returning nothing with converted to 0 in ID.  I changed the datatype of ID to nullable (of integer)  and the if worked.  The hex values was because the hexadecimal display button was depressed.  until a few minuets ago, I did not know about this.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
How many times a day do you open, acknowledge, or close an IT incident? What’s your process? Do you have a process depending on the incident, systems involved, and other factors? New Relic Alerts gives you options for how you interact with notifica…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question