team2005
asked on
How to check NULL value when using MysqlReader..
Hi!
Have this included source...
But it fails, if one or more values is NULL
How can i check if the value is NULL ?
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi!
That dosent work, but thanks to you
i find the right way.
If myReader.IsDBNull(3) Then
Merke.Text = ""
Else
Merke.Text = myReader.GetString(3)
End If
Thanks for help, give you the points...
That dosent work, but thanks to you
i find the right way.
If myReader.IsDBNull(3) Then
Merke.Text = ""
Else
Merke.Text = myReader.GetString(3)
End If
Thanks for help, give you the points...
ASKER