Using libmysql.dll via "loadLibrary()"

Post Reply
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Using libmysql.dll via "loadLibrary()"

Post by JC »

Dear Antonio and friends of forum!

I have tried to connect into a mysql server calling the functions of libmysq.dll with loadLib32() function.

The function mysql_init() for prepare the threads and environment to connect on the database server is running perfectly! I get a code handle for this!

But, some functions like mysql_real_connect() and others... they are not running correctly.

The fivewin, at runtime, crashing with a GPF error!

Bellow, I describe my code... Please, help me!

Code: Select all

# include "Fivewin.ch"

STATIC cMySqlLib32
STATIC hHandleConexao

// ------------
FUNCTION main()
// ------------

cMySqlLib32 := loadLib32( "libmysql.dll" )

hHandleConexao := mysql_init()

IF !mysql_real_connect( hHandleConexao, "127.0.0.1", "root", "mysql", NIL, 0, NIL )
   ? "Not connected!"
ELSE
   ? "Connected!"
ENDIF

mysql_close( hHandleConexao )

RETURN( NIL )


*** *************************************** ****
*** Declaration of funciotns at libmysq.dll ****
*** *************************************** ****
DLL32 STATIC FUNCTION mysql_init( mysql AS LPSTR ) AS LONG PASCAL FROM "mysql_init" LIB cMySqlLib32
DLL32 STATIC FUNCTION mysql_close( mysql AS LPSTR ) AS LONG PASCAL FROM "mysql_close" LIB cMySqlLib32

DLL32 STATIC FUNCTION mysql_real_connect( mysql AS LPSTR, ;
                                          host AS LPSTR, ;
                                          user AS LPSTR, ;
                                          passwd AS LPSTR, ;
                                          db AS LPSTR, ;
                                          port AS LPSTR, ;
                                          unix_socket AS LPSTR, ;
                                          client_flag AS LPSTR ) AS BOOL PASCAL FROM "mysql_real_connect" LIB cMySqlLib32
Last edited by JC on Tue Jul 29, 2008 6:19 pm, edited 1 time in total.
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Post by JC »

Nobody?
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post by ShumingWang »

JC,
Pls import libmysql.lib from libmysql.dll ,link libmysql.lib,mysql.lib (tmysql.prg,mysql.c,mysql.ch,mysql server 5.0/include ) into your app, you can directly use tmysql.prg .
Regards!
Shuming Wang
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Please use LoadLibrary() and DLL FUNCTION ...

LoadLib32() and DLL32 FUNCTION are for 16 bits apps.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Post by JC »

ShumingWang wrote:JC,
Pls import libmysql.lib from libmysql.dll ,link libmysql.lib,mysql.lib (tmysql.prg,mysql.c,mysql.ch,mysql server 5.0/include ) into your app, you can directly use tmysql.prg .
Regards!
Shuming Wang
Shuming, I tried to use the libmysql.lib but, returns the following error:

Code: Select all

Error: 'H:\FWH8.06\FWH\SAMPLES\LIBMYSQL.LIB' contains invalid OMF record, type 0
x21 (possibly COFF)
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Post by JC »

Antonio Linares wrote:Please use LoadLibrary() and DLL FUNCTION ...

LoadLib32() and DLL32 FUNCTION are for 16 bits apps.
Dear Linares, thank for trip.... I will use!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post by ShumingWang »

JC,
Genarate libmysql.lib from libmysql.dll, libmysql.dlls are different among different Mysql versions.
\bcc55\bin\implib.exe libmysql.lib libmysql.dll
Regards!
Shuming Wang
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Post by JC »

ShumingWang wrote:JC,
Genarate libmysql.lib from libmysql.dll, libmysql.dlls are different among different Mysql versions.
\bcc55\bin\implib.exe libmysql.lib libmysql.dll
Regards!
Shuming Wang
Thanks Shuming... it's work! I will try now!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Post by JC »

Shuming, it's work now with libmysql.lib via implib.exe

But, the function mysql_real_connect() still not recognized :(

I will go work better! Thanks for all!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Post Reply