We help IT Professionals succeed at work.
Get Started

How to check NULL value when using MysqlReader..

team2005
team2005 asked
on
565 Views
Last Modified: 2013-12-25
Hi!

Have this included source...
But it fails, if one or more values is NULL

How can i check if the value is NULL ?
Private Sub arbordrevise(ByVal arbnr As Integer)
        Dim mySelectQuery As String = "SELECT * FROM arb_ordre WHERE Arb_ordreID = '" & arbnr & "'"
        Dim connstr2 As String = "Database=hms;Data Source=localhost;User Id=root;Password=root"
        Dim myConnection As New MySqlConnection(connstr2)
        Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
        myConnection.Open()
        Dim myReader As MySqlDataReader
        myReader = myCommand.ExecuteReader()
        ' Always call Read before accessing data.
 
 
        While myReader.Read()
            Beskrivelse.Text = myReader.GetString(2)
            ' HOW TO CHECK NULL VALUE ?????
            ' If IsDBNull(myReader.GetString(3)) Then
            'Merke.Text = ""
            'Else
            'Merke.Text = myReader.GetString(3)
            'End If
 
            Merke.Text = myReader.GetString(3)
            Regnummer.Text = myReader.GetString(4)
            Motornummer.Text = myReader.GetString(5)
            Deres_referanse.Text = myReader.GetString(11)
            tekst.Text = myReader.GetString(13)
            Plassering.Text = myReader.GetString(17)
            RegistrertDato.Text = myReader.GetString(7)
            levering.Text = myReader.GetString(16)
            start.Text = myReader.GetString(18)
            tidsforbruk.Text = myReader.GetInt32(19)
        End While
        ' always call Close when done reading.
        myReader.Close()
        ' Close the connection when done with it.
        myConnection.Close()
    End Sub

Open in new window

Comment
Watch Question
Project manager
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE