Variable type

  • Thread starter Thread starter Teo
  • Start date Start date
T

Teo

What type of format is the field that is retrieved from the DB using a data
reader?
I can display the content into a msgbox but not a textbox.

TEo
 
Teo,

DataReader.Read returns a row from a database (not a field)
You access the fields (columns) using its position in the row
If you know that the column is a particular type then use one of the ,Getxxx
methods
eg, If you know that the first column is a string
Dim str as String = myReader.GetString(0)
If you just use myReader(0) then performance is affected (data needs to be
converted)
You would then need to test the object type (if TypeOf....) or use the
..ToString method if you want to convert it to a string
Stephen
 
Thanks much Stephen,
The problem I am getting is that I'm trying to retrieve a row from the DB. I
get to retrieve the row fine if I want to display it into a messagebox but
if I want to display it into a text box, the form doesn't fill up the
textboxes.
I'm just using the Reader.Item("Fieldname").ToString()
to specify each field to be able to display into the textbox. However that
doesn't show anything on my textboxes but if I try it on my msgbox it works
and shows me the different fields of the row.

Teo
 
Back
Top