#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
#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
#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
#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
#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
#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
#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
Return to FiveWin for Pocket PC
Users browsing this forum: No registered users and 2 guests