Reading Empty Cells

haroldjclements

Well-known member
Joined
Jun 13, 2004
Messages
46
I have a problem with reading null value from my database. The connection works and does retrieve the data. However if there is an empty cell in the database it creates an exception
 
ok, I have worked it out. Using the try and catch you can tell your program to just ignore that error.

Hope this helps someone.
Harold
 
Try checking to see if the value is null before assigning it to the string. Youll find this alot quicker than catching an exception.
 
Ok found it:

Code:
if (myDataReader.IsDBNull(5)){textBox3.set_Text("");}
else {textBox3.set_Text(myDataReader.GetString(5));}

Cheers,
Harold Clements
 
Back
Top