Board index » delphi » Getting native ODBC *statement* handles (not database handles)

Getting native ODBC *statement* handles (not database handles)

Can anyone explain why the following code, trying to retrieve a native
ODBC *statement*  handle from out of the BDE black box, does not
retrieve anything usefull?
(I tried various bde version's up till 451)

var
 Query1:TQuery;
 hNatStmt: longint;
 len:word;
begin
  Check(DbiGetProp(hDbiObj(Query1.StmtHandle), stmtNATIVEHNDL,
@hNatstmt, sizeof(hNatstmt), Len));
  // here we only find a stupid byte value of 3 for hNatStmt meaning???

end;
(Query1 is active, RequestLive=true...)

I know the following code to retrieve an ODBC database handle from out
of the BDE works perfect.

var
 ODBCDB: TDataBase;
  hNatDb: longint;
  len:word;
begin
  Check(DbiGetProp(hDbiObj(ODBCDb.Handle), dbNATIVEHNDL, @hNatDb,
sizeof(hNatDb), Len));
  // here we got HnatDB ....
end;

Any help would really be appreciated,
Frank

 

Re:Getting native ODBC *statement* handles (not database handles)


Hi, Frank.

Quote
> var
>  Query1:TQuery;
>  hNatStmt: longint;
>  len:word;
> begin
>   Check(DbiGetProp(hDbiObj(Query1.StmtHandle), stmtNATIVEHNDL,
> @hNatstmt, sizeof(hNatstmt), Len));
>   // here we only find a stupid byte value of 3 for hNatStmt meaning???

Yesss !!! I can do it.

I correct this BUG in the binary file !!!
It works.

File IDODBC32.DLL version 4.51 offset 3DF11h :
4DA1E911 0F845A010000   je     IDODBC32.4DA1EA71
4DA1E917 0FB755FC       movzx  edx,word ptr [ebp-04]
4DA1E91B 52             push   edx
4DA1E91C FF75CC         push   dword ptr [ebp-34]
4DA1E91F 56             push   esi
4DA1E920>E83B740000     call   IDODBC32.4DA25D60

need change to

4DA1E911 7415           je     IDODBC32.4DA1E928 (4DA1
4DA1E913 0FB755FC       movzx  edx,word ptr [ebp-04]
4DA1E917 52             push   edx
4DA1E918 8D55CC         lea    edx,[ebp-34]
4DA1E91B 52             push   edx
4DA1E91C 90             nop
4DA1E91D 90             nop
4DA1E91E 90             nop
4DA1E91F 56             push   esi
4DA1E920>E83B740000     call   IDODBC32.4DA25D60

E-mail me if you want to get and test corrected IDODBC32.DLL.

Question to BORLAND : How do you think , is better correct BUG in bynary
files or in source codes ?

Best regards,
Dmitriy Anisimkov.

Re:Getting native ODBC *statement* handles (not database handles)


Dmitriy,
thank you very much. At least one serious programmer reading these
newsgroup!
I have written a small program which loads IDODBC32.DLL, pokes some
bytes and saves the corrected version.
Whereas we get now the ODBC handle, we are still unable to do a

SqlCancel(odbchstmt).

Are you able to cancel (long running) queries?
Have you had any comment from Borland?

Frank Bevers

Remember : Real programmers do it on interrupts.

Other Threads