Hello, I am getting into troubles with the SQLBindCol function and hope someone can help me...

I started with the excellent Iczelion's tutorial so my code example is taken from there; what I want to realize is a dinamical binding of columns so I have to realize it in some way...

This code works : ( from Icz tut )

lea eax, IDLength
push eax
push sizeof ID
lea eax, ID
push eax
push SQL_C_CHAR
push 1; (first col)
push hStmt
call SQLBindCol ;Data Binding

having :

ID db 50 dup(?);Buffer
IDLength dd ?;Pointer

For the next column in the tutorial you have to bind data for NAME etc... until you can finally call SQLFetch for the entire row.

Ok, and what if I have a variable number of columns ? I can use SQLNumResultCols to retrieve this info :

lea eax, NumCols
push eax
push hStmt
call SQLNumResultCols

having :

NumCols dd ?

This works too but this DOESN'T WORKS :

;;;;BINDING A VARIABLE NUMBER OF COLS ( MAX 10 FOR NOW OF 50 BYTES EACH );;;;;;

;;ecx contains NumCols

mov ebx, 0
mov edx, 0

Binding:
inc ebx;num of col
lea eax, FieldLength +
push eax
push 50
lea eax, Field +
add edx, 50
push eax
push SQL_C_CHAR
push ebx
push hStmt
call SQLBindCol ;Data Binding
loop Binding


Field db 500 dup(?);Buffer - ten fields of 50 each
FieldLength dd 500 (?); pointers to each field

I think I need an array of pointers and an array of corresponding buffers...the idea is to associate a pointer with a buffer by an offset in register edx...but something is going wrong....If it is not possible ( I don't think so ) I have to define each buffer and each pointer manually.

Thanks in advance,

fooCoder
Posted on 2002-11-09 05:47:22 by fooCoder
...mmm.... I think the question is here in the form of this instruction :

lea eax, Field +

edx should contain the offset....

Load Effective Address of (Field+edx)

I tried to do so :

lea eax, Field
add eax, edx
push eax

lea eax, FieldLength + ; pointers are 32 bits long


But it doesn't work...yet
Posted on 2002-11-09 07:16:28 by fooCoder
What is the return value of SQLBindCol ? Where in your loop do you preserve edx ?
Posted on 2002-11-09 16:48:06 by micmic