Using ADOCE
Re: Using ADOCE
Dear Mr.Antonio and Mr.Sergio,
Thankyou very much for the info and the sample . I was looking for a solution on how a FWPPC application can access a MYSQL Database installed on a server and MySQL support on Windows Mobile devices. I understand that MySQLMobile is a commercial software. I hope that we can create FWPPC compatible lib as demonstarated by you, once we purchase a Full version of MySqlMobile.
Regards
Anser
Thankyou very much for the info and the sample . I was looking for a solution on how a FWPPC application can access a MYSQL Database installed on a server and MySQL support on Windows Mobile devices. I understand that MySQLMobile is a commercial software. I hope that we can create FWPPC compatible lib as demonstarated by you, once we purchase a Full version of MySqlMobile.
Regards
Anser
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using ADOCE
Sergio,
> The Test return 0 (é normal)
Yes, it is ok!
It means connected!
>
Podemos tentar Ligar
MyExeQuery ? - Executar uma query
MySelectDb ? - Abrir Base de Dados
MyDesconec ? - Desconectar
>
Yes, lets do it
> The Test return 0 (é normal)
Yes, it is ok!
It means connected!
>
Podemos tentar Ligar
MyExeQuery ? - Executar uma query
MySelectDb ? - Abrir Base de Dados
MyDesconec ? - Desconectar
>
Yes, lets do it
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using ADOCE
A new test.prg with mysql errors support:
test.prg
test.prg
Code: Select all
#include "FWCE.ch"
function Main()
local nRet := MySQL_Connect( "192.168.0.30", 3306, "username", "password" )
if nRet == 0
MsgInfo( "successful connection" )
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
return nil
#pragma BEGINDUMP
int mysql_connect( char * host, int iPort, char * pszUsername, char * pszPassword );
void mysql_get_last_error( int nErrorCode, char * pszError );
#include <hbapi.h>
HB_FUNC( MYSQL_CONNECT )
{
hb_retnl( mysql_connect( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ) ) );
}
HB_FUNC( MYSQL_GET_LAST_ERROR )
{
char error[ 255 ];
mysql_get_last_error( hb_parnl( 1 ), error );
hb_retc( error );
}
#pragma ENDDUMP
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using ADOCE
A new version with disconnect support:
test.prg
test.prg
Code: Select all
#include "FWCE.ch"
function Main()
local nRet := MySQL_Connect( "192.168.0.30", 3306, "username", "password" )
if nRet == 0
MsgInfo( "successful connection" )
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
MySQL_Disconnect()
return nil
#pragma BEGINDUMP
int mysql_connect( char * host, int iPort, char * pszUsername, char * pszPassword );
void mysql_get_last_error( int nErrorCode, char * pszError );
int mysql_disconnect( void );
#include <hbapi.h>
HB_FUNC( MYSQL_CONNECT )
{
hb_retnl( mysql_connect( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ) ) );
}
HB_FUNC( MYSQL_GET_LAST_ERROR )
{
char error[ 255 ];
mysql_get_last_error( hb_parnl( 1 ), error );
hb_retc( error );
}
HB_FUNC( MYSQL_DISCONNECT )
{
mysql_disconnect();
}
#pragma ENDDUMP
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using ADOCE
Selecting the database to work with:
test.prg
test.prg
Code: Select all
#include "FWCE.ch"
function Main()
local nRet := MySQL_Connect( "192.168.0.30", 3306, "username", "password" )
if nRet == 0
MsgInfo( "successful connection" )
nRet = MySQL_Select_DB( "test" )
if nRet == 0
MsgInfo( "database properly selected" )
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
MySQL_Disconnect()
return nil
#pragma BEGINDUMP
int mysql_connect( char * host, int iPort, char * pszUsername, char * pszPassword );
void mysql_get_last_error( int nErrorCode, char * pszError );
int mysql_disconnect( void );
int mysql_select_db( char * pszDatabaseName );
#include <hbapi.h>
HB_FUNC( MYSQL_CONNECT )
{
hb_retnl( mysql_connect( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ) ) );
}
HB_FUNC( MYSQL_GET_LAST_ERROR )
{
char error[ 255 ];
mysql_get_last_error( hb_parnl( 1 ), error );
hb_retc( error );
}
HB_FUNC( MYSQL_DISCONNECT )
{
mysql_disconnect();
}
HB_FUNC( MYSQL_SELECT_DB )
{
hb_retnl( mysql_select_db( hb_parc( 1 ) ) );
}
#pragma ENDDUMP
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using ADOCE
Doing a SQL query:
test.prg
test.prg
Code: Select all
#include "FWCE.ch"
#define MYSQL_PORT 3306
function Main()
local nRet := MySQL_Connect( "192.168.0.30", MYSQL_PORT, "username", "password" )
if nRet == 0
MsgInfo( "successful connection" )
nRet = MySQL_Select_DB( "test" )
if nRet == 0
MsgInfo( "database properly selected" )
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
nRet = MySQL_Execute_Query( "SELECT * FROM Customers LIMIT 100" )
if nRet != 0
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
MySQL_Disconnect()
return nil
#pragma BEGINDUMP
int mysql_connect( char * host, int iPort, char * pszUsername, char * pszPassword );
void mysql_get_last_error( int nErrorCode, char * pszError );
int mysql_disconnect( void );
int mysql_select_db( char * pszDatabaseName );
int mysql_execute_query( char * pszQueryString );
#include <hbapi.h>
HB_FUNC( MYSQL_CONNECT )
{
hb_retnl( mysql_connect( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ) ) );
}
HB_FUNC( MYSQL_GET_LAST_ERROR )
{
char error[ 255 ];
mysql_get_last_error( hb_parnl( 1 ), error );
hb_retc( error );
}
HB_FUNC( MYSQL_DISCONNECT )
{
mysql_disconnect();
}
HB_FUNC( MYSQL_SELECT_DB )
{
hb_retnl( mysql_select_db( hb_parc( 1 ) ) );
}
HB_FUNC( MYSQL_EXECUTE_QUERY )
{
hb_retnl( mysql_execute_query( hb_parc( 1 ) ) );
}
#pragma ENDDUMP
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using ADOCE
A live test against http://www.FreeMySQL.net:
test.prg
test.prg
Code: Select all
#include "FWCE.ch"
#define MYSQL_PORT 3306
function Main()
local nRet := MySQL_Connect( "SQL06.FREEMYSQL.NET", MYSQL_PORT, "fivetech", "fivewin" ) // username, password
if nRet == 0
MsgInfo( "successful connection" )
nRet = MySQL_Select_DB( "fwppc" )
if nRet == 0
MsgInfo( "database properly selected" )
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
nRet = MySQL_Execute_Query( "SELECT * FROM customers LIMIT 100" )
if nRet != 0
MsgInfo( MySQL_Get_Last_Error( nRet ) )
else
MsgInfo( "Number of fields: " + Str( MySQL_Get_FieldCount() ) )
endif
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
MySQL_Disconnect()
return nil
#pragma BEGINDUMP
int mysql_connect( char * host, int iPort, char * pszUsername, char * pszPassword );
void mysql_get_last_error( int nErrorCode, char * pszError );
int mysql_disconnect( void );
int mysql_select_db( char * pszDatabaseName );
int mysql_execute_query( char * pszQueryString );
int mysql_get_fieldcount( void );
#include <hbapi.h>
HB_FUNC( MYSQL_CONNECT )
{
hb_retnl( mysql_connect( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ) ) );
}
HB_FUNC( MYSQL_GET_LAST_ERROR )
{
char error[ 255 ];
mysql_get_last_error( hb_parnl( 1 ), error );
hb_retc( error );
}
HB_FUNC( MYSQL_DISCONNECT )
{
mysql_disconnect();
}
HB_FUNC( MYSQL_SELECT_DB )
{
hb_retnl( mysql_select_db( hb_parc( 1 ) ) );
}
HB_FUNC( MYSQL_EXECUTE_QUERY )
{
hb_retnl( mysql_execute_query( hb_parc( 1 ) ) );
}
HB_FUNC( MYSQL_GET_FIELDCOUNT )
{
hb_retnl( mysql_get_fieldcount() );
}
#pragma ENDDUMP
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using ADOCE
Getting the fieldnames:
test.prg
test.prg
Code: Select all
#include "FWCE.ch"
#define MYSQL_PORT 3306
function Main()
local nRet := MySQL_Connect( "SQL06.FREEMYSQL.NET", MYSQL_PORT, "fivetech", "fivewin" ) // username, password
local nFields, cFieldName
if nRet == 0
MsgInfo( "successful connection" )
nRet = MySQL_Select_DB( "fwppc" )
if nRet == 0
MsgInfo( "database properly selected" )
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
nRet = MySQL_Execute_Query( "SELECT * FROM customers LIMIT 100" )
if nRet != 0
MsgInfo( MySQL_Get_Last_Error( nRet ) )
else
MsgInfo( "Number of fields: " + Str( nFields := MySQL_Get_FieldCount() ) )
for n = 1 to nFields
MySQL_Get_Field( n, @cFieldName )
MsgInfo( AllTrim( Str( n ) ) + ": " + cFieldName )
next
endif
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
MySQL_Disconnect()
MsgInfo( "done!" )
return nil
#pragma BEGINDUMP
// field parameters for mysql_get_field_param() function
#define FIELD_PARAM_CATALOG 1
#define FIELD_PARAM_DB 2
#define FIELD_PARAM_TABLE 3
#define FIELD_PARAM_ORIGTABLE 4
#define FIELD_PARAM_FIELD 5
#define FIELD_PARAM_ORIGFIELD 6
#define FIELD_PARAM_LENGTH 7
#define FIELD_PARAM_TYPE 8
#define FIELD_PARAM_FLAGS 9
#define FIELD_PARAM_DECIMALS 10
int mysql_connect( char * host, int iPort, char * pszUsername, char * pszPassword );
void mysql_get_last_error( int nErrorCode, char * pszError );
int mysql_disconnect( void );
int mysql_select_db( char * pszDatabaseName );
int mysql_execute_query( char * pszQueryString );
int mysql_get_fieldcount( void );
int mysql_get_field( char * char_val, int * int_val, int nParam, int nIndex );
#include <hbapi.h>
HB_FUNC( MYSQL_CONNECT ) // cHost, nPort, cUserName, cPassword
{
hb_retnl( mysql_connect( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ) ) );
}
HB_FUNC( MYSQL_GET_LAST_ERROR ) // nCode --> cError
{
char error[ 255 ];
mysql_get_last_error( hb_parnl( 1 ), error );
hb_retc( error );
}
HB_FUNC( MYSQL_DISCONNECT )
{
mysql_disconnect();
}
HB_FUNC( MYSQL_SELECT_DB ) // cDataBaseName --> nRet
{
hb_retnl( mysql_select_db( hb_parc( 1 ) ) );
}
HB_FUNC( MYSQL_EXECUTE_QUERY ) // cSQLQuery --> nRet
{
hb_retnl( mysql_execute_query( hb_parc( 1 ) ) );
}
HB_FUNC( MYSQL_GET_FIELDCOUNT ) // --> nFields
{
hb_retnl( mysql_get_fieldcount() );
}
HB_FUNC( MYSQL_GET_FIELD ) // nField, @cName --> nRet
{
char fieldname[ 255 ];
int int_buffer, iRet;
iRet = mysql_get_field( fieldname, &int_buffer, FIELD_PARAM_FIELD, hb_parnl( 1 ) - 1 );
hb_storc( fieldname, 2 );
hb_retnl( iRet );
}
#pragma ENDDUMP
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using ADOCE
Retrieving fields values!
test.prg
test.prg
Code: Select all
#include "FWCE.ch"
#define MYSQL_PORT 3306
function Main()
local nRet := MySQL_Connect( "SQL06.FREEMYSQL.NET", MYSQL_PORT, "fivetech", "fivewin" ) // username, password
local nFields, cFieldName, n, nRow, nField, cFieldValue
if nRet == 0
MsgInfo( "successful connection" )
nRet = MySQL_Select_DB( "fwppc" )
if nRet == 0
MsgInfo( "database properly selected" )
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
nRet = MySQL_Execute_Query( "SELECT * FROM customers LIMIT 100" )
if nRet != 0
MsgInfo( MySQL_Get_Last_Error( nRet ) )
else
MsgInfo( "Number of fields: " + Str( nFields := MySQL_Get_FieldCount() ) )
for n = 1 to nFields
MySQL_Get_Field( n, @cFieldName )
MsgInfo( AllTrim( Str( n ) ) + ": " + cFieldName )
next
for n = 1 to MySQL_Get_RowCount()
for nField = 1 to MySQL_Get_FieldCount()
MySQL_Get_Data( @cFieldValue, nRow, nField )
MsgInfo( cFieldValue )
next
next
endif
else
MsgInfo( MySQL_Get_Last_Error( nRet ) )
endif
MySQL_Disconnect()
MsgInfo( "done!" )
return nil
#pragma BEGINDUMP
// field parameters for mysql_get_field_param() function
#define FIELD_PARAM_CATALOG 1
#define FIELD_PARAM_DB 2
#define FIELD_PARAM_TABLE 3
#define FIELD_PARAM_ORIGTABLE 4
#define FIELD_PARAM_FIELD 5
#define FIELD_PARAM_ORIGFIELD 6
#define FIELD_PARAM_LENGTH 7
#define FIELD_PARAM_TYPE 8
#define FIELD_PARAM_FLAGS 9
#define FIELD_PARAM_DECIMALS 10
int mysql_connect( char * host, int iPort, char * pszUsername, char * pszPassword );
void mysql_get_last_error( int nErrorCode, char * pszError );
int mysql_disconnect( void );
int mysql_select_db( char * pszDatabaseName );
int mysql_execute_query( char * pszQueryString );
int mysql_get_fieldcount( void );
int mysql_get_field( char * char_val, int * int_val, int nParam, int nIndex );
int mysql_get_rowcount( void );
int mysql_get_data( char * pszElem, int nRow, int nColumn );
#include <hbapi.h>
HB_FUNC( MYSQL_CONNECT ) // cHost, nPort, cUserName, cPassword
{
hb_retnl( mysql_connect( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ) ) );
}
HB_FUNC( MYSQL_GET_LAST_ERROR ) // nCode --> cError
{
char error[ 255 ];
mysql_get_last_error( hb_parnl( 1 ), error );
hb_retc( error );
}
HB_FUNC( MYSQL_DISCONNECT )
{
mysql_disconnect();
}
HB_FUNC( MYSQL_SELECT_DB ) // cDataBaseName --> nRet
{
hb_retnl( mysql_select_db( hb_parc( 1 ) ) );
}
HB_FUNC( MYSQL_EXECUTE_QUERY ) // cSQLQuery --> nRet
{
hb_retnl( mysql_execute_query( hb_parc( 1 ) ) );
}
HB_FUNC( MYSQL_GET_FIELDCOUNT ) // --> nFields
{
hb_retnl( mysql_get_fieldcount() );
}
HB_FUNC( MYSQL_GET_FIELD ) // nField, @cName --> nRet
{
char fieldname[ 255 ];
int int_buffer;
hb_retnl( mysql_get_field( fieldname, &int_buffer, FIELD_PARAM_FIELD, hb_parnl( 1 ) - 1 ) );
hb_storc( fieldname, 2 );
}
HB_FUNC( MYSQL_GET_ROWCOUNT ) // --> nRows
{
hb_retnl( mysql_get_rowcount() );
}
HB_FUNC( MYSQL_GET_DATA ) // @cFieldData, nRow, nField --> nRet
{
char buffer[ 8192 ]; // max data size = 8K
hb_retnl( mysql_get_data( buffer, hb_parnl( 2 ) - 1, hb_parnl( 3 ) - 1 ) );
hb_storc( buffer, 1 );
}
#pragma ENDDUMP
Re: Using ADOCE
Excelent Linares
I testing with LAN - WIFI - it´s ok
I testing with NET - 3G - GPRS - it´s ok
FWPPC - In Progress
Regards, Saludos
Sergio
I testing with LAN - WIFI - it´s ok
I testing with NET - 3G - GPRS - it´s ok
FWPPC - In Progress
Regards, Saludos
Sergio
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using ADOCE
Sergio,
Yes, it is working very nicely
Thanks for your feedback,
Yes, it is working very nicely
Thanks for your feedback,
Re: Using ADOCE
Linares
Acabei por comprar o Mysqlmobile.dll - Versão 7 - full version
now i testing your test.prg
MySQL_Connect - Return OK
MySQL_Select_DB - Return OK
But after return the ERROR FIX GPFStack() in the your file test.prg
Regards
Sergio
Acabei por comprar o Mysqlmobile.dll - Versão 7 - full version
now i testing your test.prg
MySQL_Connect - Return OK
MySQL_Select_DB - Return OK
But after return the ERROR FIX GPFStack() in the your file test.prg
Regards
Sergio
Re: Using ADOCE
Hello Antonio
I add echo MySQLMobile.lib >> msvc.tmp into the buildce.bat
But I have this error
SQLNet.obj : error LNK2019: unresolved external symbol "void __cdecl mysql_get_l
ast_error(int,char *)" (?mysql_get_last_error@@YAXHPAD@Z) referenced in function
HB_FUN_MYSQL_GET_LAST_ERROR
SQLNet.obj : error LNK2019: unresolved external symbol "int __cdecl mysql_discon
nect(void)" (?mysql_disconnect@@YAHXZ) referenced in function HB_FUN_MYSQL_DISCO
NNECT
SQLNet.obj : error LNK2019: unresolved external symbol "int __cdecl mysql_select
_db(char *)" (?mysql_select_db@@YAHPAD@Z) referenced in function HB_FUN_MYSQL_SE
LECT_DB
SQLNet.obj : error LNK2019: unresolved external symbol "int __cdecl mysql_execut
e_query(char *)" (?mysql_execute_query@@YAHPAD@Z) referenced in function HB_FUN_
MYSQL_EXECUTE_QUERY
SQLNet.obj : error LNK2019: unresolved external symbol "int __cdecl mysql_get_fi
eldcount(void)" (?mysql_get_fieldcount@@YAHXZ) referenced in function HB_FUN_MYS
QL_GET_FIELDCOUNT
SQLNet.obj : error LNK2019: unresolved external symbol "int __cdecl mysql_get_fi
eld(char *,int *,int,int)" (?mysql_get_field@@YAHPADPAHHH@Z) referenced in funct
ion HB_FUN_MYSQL_GET_FIELD
SQLNet.exe : fatal error LNK1120: 7 unresolved externals
Regards MAurizio
I add echo MySQLMobile.lib >> msvc.tmp into the buildce.bat
But I have this error
SQLNet.obj : error LNK2019: unresolved external symbol "void __cdecl mysql_get_l
ast_error(int,char *)" (?mysql_get_last_error@@YAXHPAD@Z) referenced in function
HB_FUN_MYSQL_GET_LAST_ERROR
SQLNet.obj : error LNK2019: unresolved external symbol "int __cdecl mysql_discon
nect(void)" (?mysql_disconnect@@YAHXZ) referenced in function HB_FUN_MYSQL_DISCO
NNECT
SQLNet.obj : error LNK2019: unresolved external symbol "int __cdecl mysql_select
_db(char *)" (?mysql_select_db@@YAHPAD@Z) referenced in function HB_FUN_MYSQL_SE
LECT_DB
SQLNet.obj : error LNK2019: unresolved external symbol "int __cdecl mysql_execut
e_query(char *)" (?mysql_execute_query@@YAHPAD@Z) referenced in function HB_FUN_
MYSQL_EXECUTE_QUERY
SQLNet.obj : error LNK2019: unresolved external symbol "int __cdecl mysql_get_fi
eldcount(void)" (?mysql_get_fieldcount@@YAHXZ) referenced in function HB_FUN_MYS
QL_GET_FIELDCOUNT
SQLNet.obj : error LNK2019: unresolved external symbol "int __cdecl mysql_get_fi
eld(char *,int *,int,int)" (?mysql_get_field@@YAHPADPAHHH@Z) referenced in funct
ion HB_FUN_MYSQL_GET_FIELD
SQLNet.exe : fatal error LNK1120: 7 unresolved externals
Regards MAurizio
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using ADOCE
Maurizio,
You are compiling, with the C compiler, using C++ mode.
Please remove the /Tp flag, thanks
You are compiling, with the C compiler, using C++ mode.
Please remove the /Tp flag, thanks
Re: Using ADOCE
For user´s the DLL MySQLMobile Version 1.7
Modify respectiv MySQLMobile.LIB in ...\vce\lib\arm\
download file in
http://www.briweb.net/software/c/MySQLMobile.lib
in build.bat
.......\MySQLMobile.lib >> msvc.tmp
I´Testing and RUN OK
Best REGARDS
Sergio
Modify respectiv MySQLMobile.LIB in ...\vce\lib\arm\
download file in
http://www.briweb.net/software/c/MySQLMobile.lib
in build.bat
.......\MySQLMobile.lib >> msvc.tmp
I´Testing and RUN OK
Best REGARDS
Sergio