Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28633 Discussions

Reading text fields from a database in IVF

monarchi
Beginner
266 Views
Hi -

I can read integer data from a database. For example to read a 16-bit integer, I can use the following snippet

integer(2) :: dataField1
type(variant) :: vBstr1, vTName
integer(4) ADOField, ADORecSet

call $Recordset_Movenext(ADORecSet, status)
ADOField = Fields_GetItem(ADORecSet, vBSTR1, status)
vTName = Field_GetValue(ADOField, status)
dataField1 = vtName%vu%short_val
print *,"Field 1 ",dataField1

and everything works fine. But I can't figure out the "magic combination" to read text data. I can obtain the contents of the field with

ADOField2 = Fields_GetItem(ADORecSet,vBSTR2,status)
vTName = Field_GetValue(ADOField,status)

but can't figure out how to get from there to a string. I tried, for example,

character(50) :: dataField2

dataField2 = vTName%vu%char_val
print *,"Field 2 ",dataField2

but that just returns a single wide character. I looked for a string_val on vTName in the debugger but didn't find one. I suspect that I want to use the ptr_val of VTName and then ConvertBSTRToString, but so far I can't get the details correct.

Any help/references would be appreciated.

Thank you.

david
0 Kudos
1 Reply
ronald_g_guenther
266 Views
Greetings,
I am just guessing as I haven't seen your database, but the "TEXT" fields are probably stored as variable length character attributes(tuples). As I do not use ADO calls, I cannot give you the correct codes, but believe that there is one for what is known as a Varchar or Nchar.
0 Kudos
Reply