Can't loop using a single query
Posted by: RIO Philippe
Date: June 01, 2011 09:41AM

My query is "SELCT * FROM Tbl_Users"

Very basic.
I get the first record but none of the two others records.

I am coding using assembly language and I use mysql V5.5.12
I can insert/update into all the tables I have.
Using the same query under Heidi gives me three records, but me I only get ONE.
Here is my code :



;===========================================================================================
ALIGN 16
;===========================================================================================

User_ReadEx PROC __lpszQuery:LPSTR,__lpFunction:LPVOID,__lParam:LPARAM
LOCAL _lpUser:LPF32_USER
LOCAL _hResult:HANDLE

@@ :

INVOKE mysql_next_result,hMySql

test eax,eax
jz @B

INVOKE PhR_Memory_Alloc,SIZEOF F32_USER

test eax,eax
jnz @Begin

stc
ret

;-------------------------------------------------------------------------------------------
ALIGN 16
;-------------------------------------------------------------------------------------------

@Begin :

mov _lpUser,eax

INVOKE lstrlen,__lpszQuery
INVOKE mysql_real_query,hMySql,__lpszQuery,eax

test eax,eax
jz @Success

INVOKE PhR_Memory_Free,_lpUser

call mysql_errno

stc
ret

;-------------------------------------------------------------------------------------------
ALIGN 16
;-------------------------------------------------------------------------------------------

@Error :

push eax
INVOKE PhR_Memory_Free,_lpUser
pop eax

stc
ret

;-------------------------------------------------------------------------------------------
ALIGN 16
;-------------------------------------------------------------------------------------------

@Success :

INVOKE mysql_store_result,hMySql

test eax,eax
jnz @ReadyToGetData

call mysql_errno

test eax,eax
jz @Error

INVOKE mysql_field_count,hMySql

test eax,eax
jnz @ReadyToGetData

mov eax,_lpUser
clc

stc
ret

;-------------------------------------------------------------------------------------------
ALIGN 16
;-------------------------------------------------------------------------------------------

@ReadyToGetData :

mov _hResult,eax

INVOKE User_Get,eax,_lpUser

INVOKE mysql_free_result,_hResult

push _lpUser
push __lParam
call __lpFunction

INVOKE mysql_next_result,hMySql

test eax,eax
jz @Success

INVOKE PhR_Memory_Free,_lpUser

mov eax,TRUE
clc
ret
User_ReadEx ENDP

The problem is that after getting the first record, mysql_next_result returns -1.

And the following code is the function which retrieves datas


;===========================================================================================
ALIGN 16
;===========================================================================================

User_Get PROC __hResult:DWord,__lpUser:LPF32_USER

push ebx
push edi
mov ebx,__lpUser

mov (F32_USER Ptr [ebx]).Pseudo_1.dwSubIndex,1
mov (F32_USER Ptr [ebx]).Pseudo_2.dwSubIndex,2
mov (F32_USER Ptr [ebx]).Pseudo_3.dwSubIndex,3
mov (F32_USER Ptr [ebx]).Pseudo_4.dwSubIndex,4
mov (F32_USER Ptr [ebx]).Pseudo_5.dwSubIndex,5

INVOKE mysql_fetch_row,__hResult

mov edi,eax

INVOKE atodw,DWord Ptr [edi]

mov (F32_USER Ptr [ebx]).dwIndexUser,eax
mov (F32_USER Ptr [ebx]).EtatCivil.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Pseudo_1.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Pseudo_2.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Pseudo_3.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Pseudo_4.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Pseudo_5.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Adresse.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Internet.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Telephone.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Signature.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Avatar.dwIndexUser,eax
mov (F32_USER Ptr [ebx]).Droits.dwIndexUser,eax

INVOKE atodw,DWord Ptr [edi + 4]

mov (F32_USER Ptr [ebx]).EtatCivil.dwIndexSexe,eax

INVOKE atodw,DWord Ptr [edi + 8]

mov (F32_USER Ptr [ebx]).EtatCivil.dwIndexCivilite,eax

mov eax,[edi + 12]

test eax,eax
jz @F

lea edx,(F32_USER Ptr [ebx]).EtatCivil.DateDeNaissance
INVOKE PhR_SQL_DateToSystemDate,NULL,eax,edx

@@ :

mov eax,[edi + 16]

test eax,eax
jz @F

lea edx,(F32_USER Ptr [ebx]).EtatCivil.szNom
INVOKE lstrcpy,edx,eax

@@ :

mov eax,[edi + 20]

test eax,eax
jz @F

lea edx,(F32_USER Ptr [ebx]).EtatCivil.szPrenom
INVOKE lstrcpy,edx,eax

@@ :

mov eax,ebx
pop edi
pop ebx
ret
User_Get ENDP

Can someone help me, not using asm but if some one already had this loop problem the solution would appreciate.

Thx

Options: ReplyQuote


Subject
Views
Written By
Posted
Can't loop using a single query
1212
June 01, 2011 09:41AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.