Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ResultSet.getString(int i) 2

Status
Not open for further replies.

pipk

Programmer
Feb 20, 2001
455
GB
I have a small problem in that I have an Access (ok, ok, crap I know) database, with tables in it within which afew fields are single character text strings i.e. simple flags

I am reading the table in question no problem, getting a populated ResultSet, and I am able to retrieve all column data that consists of numbers and long(er) strings (defined as Number and Text respectively in the table. But for some strange reason, when I try to read the column that contains the single character, the getString(int i) method of Result Set throws a wobbly and tells me there is no data, even though I have populated the field in question myself and checked to see if the data is there.

I have tried, unsuccessfully to use getByte(), but to no avail (wrong type) - is there a getChar() method in ResultSet, or something equivalent. I just can't seem to find one.

Hope you can help.

cheers

pipk ::)
 
In general, a varchar is a varchar whether it is one character or 50. You should be doing a getString(i) on this. If you like, you can try turning this resulting string into a char.

I'll tell you what. Quite often, I find it much easier to read all the data out as strings and then do the conversions to the appropriate data type when/if I need to.
 
You shouldn't have a problem since I remembered that getString can get almost everything(and that definately is including a text type in Access regardless of the field length). If you still are not very certain about this, retrieve the metadata and get the column type to take a look. It should be varchar.

If so, perhaps you are looking at the wrong column(in your codes) or at the wrong database.

Hope this helps,
Leon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top