ODBC Returning "False" value

I am trying to use an odbc connection to gain access to Oracle data in a VarChar2 format. My code keeps returning a value of “False”.

I have read that I need to use the CAST command to reformat the data into character format. That seems to be working because with that update in the Query, I know I am getting information back for “Field1” (which is the only integer value in the table), but Field2 (which is VarChar2) still returns a value of “False”.

Here is the SQL I am submitting…

QRY.SQL = “select FIELD1, cast(FIELD2 as CHAR(2000)) from TABLE_NAME”

and the “GetValue” statement which returns the “False” value…

HoldVal = Cstr(Res.GetValue(“FIELD1”)) <–WORKS!

HoldVal2 = Res.GetValue(“FIELD2”) <–Returns “False”

Can anyone tell me what I’m doing wrong? Thanks in advance for ANY help!

Subject: ODBC Returning “False” value

Have you tried it in it’s native format? I.e. not casting to type CHAR. Varchar2 just a variable length string…

It might be that your column name is not returned as ‘field2’ so try renaming it to something else e.g. TEMP_NAME.

QRY.SQL = “select FIELD1, cast(FIELD2 as CHAR(2000)) as TEMP_FIELD from TABLE_NAME”

HoldVal = Cstr(Res.GetValue(“FIELD1”))

HoldVal2 = Res.GetValue(“TEMP_FIELD”)

Cheers

Adam.

Subject: RE: ODBC Returning “False” value

Woo Hoo! Thanks, Adam!

What actually worked for me was adding the “as TEMP_FIELD” to the SQL as you suggested…and changing the “GetValue(“TEMP_FIELD”)” to “GetValue(2)”. I’ve added a couple of additional columns to the query and it seems to be working now!!

Thanks again!

Subject: RE: ODBC Returning “False” value

You are welcome! :slight_smile:

Adam.

Subject: ODBC Returning “False” value

Anita,

We always tack on “.text(0)” as in…

res.lookup(“my_column_name”).text(0)

…and that takes care of the data type confusion.

Ken A Collins

New York City