MySQL Forums
Forum List  »  Connector/ODBC

Can't display record that has NULL values
Posted by: Michelle Tay
Date: January 15, 2005 07:30AM

Hai,
below is part of my code:


Dim query As String = "SELECT * FROM tbluser"
Dim MyConn As New OdbcConnection(MyConString)
MyConn.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConn
MyCommand.CommandText = query

' search target id
While MyDataReader.Read
' target found, stop searching & display record
If (CStr(MyDataReader("user_id")) = id) Then
txtUserFindID.Text = CStr(MyDataReader("user_id"))
txtUserFName.Text = CStr(MyDataReader("user_fname"))
txtUserLName.Text = CStr(MyDataReader("user_lname"))
txtUserPswd.Text = CStr(MyDataReader("user_pwd"))
txtUserPhone1.Text = CStr(MyDataReader("user_phone"))
Exit While
End If
End While


I have a table call tbluser, which contain "user_id(PK), user_fname, user_lname, user_pwd, user_phone". At first, only user_id & user_pwd have values, other are null value. i would like to search the record based on ID & display tat record so that user can fill in other attributes' values. But when i run the code, the error msg state that "cast from type DBNULL to type String is not valid".
it is has any other solution other than hide code checking whether the attribute is Null value of not? coz if like tat i may need to do the checking for 20+ attributes & tis will slow down the performance. cld any body help me??? 10s in advance.

Options: ReplyQuote


Subject
Written By
Posted
Can't display record that has NULL values
January 15, 2005 07:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.