Well Sudip with the help of Rathinagiri (owner of HMG Forum) came out
with this working version of DBF2MYSQL using Harbour+HMG as built by
HMG IDE. BTW, this working prg also clearly demonstrates how we can
connect to MySQL via Harbor + HMG.
More at http://cch4clipper.blogspot.com
There is a function call to DATATOSQL() in this program. Where can I
find information about this function?
Thank you.
Ash
<ashf...@gmail.com> wrote in message
news:388e859e-d3ba-40dc...@g19g2000vbi.googlegroups.com...
On May 17, 12:59 am, CCH <ChongHwa.C...@gmail.com> wrote:
>> Have you ever wondered whether we can export our DBFs
>> to MySQL using Harbour ?
>
>> Well Sudip with the help of Rathinagiri (owner of HMG
>> Forum) came out with this working version of DBF2MYSQL
>> using Harbour+HMG as built by HMG IDE. BTW, this
>> working prg also clearly demonstrates how we can connect
>> to MySQL via Harbor + HMG.
>
> There is a function call to DATATOSQL() in this program.
> Where can I find information about this function?
In the file ..\contrib\mysql\mysql.c is where I find it.
First parameter is the "Buffer" of stuff to write.
Second parameter appears to be optional, and I am not sure what
it does... perhaps a sort of SQL "alias".
Mr. Culik can perhaps share a bit more...
David A. Smith
What did you use to try to compile dbf2mysql ?
Try using HMG to compile it. I had similar issue using HMG Extended to
compile it and there is a solution posted at the HMG Extended forum by
Grigory Filatov.
CCH
http://cch4clipper.blogspot.com
I am using HMG Extended (builds 66 and 67). I also tried regular HMG
and dbf2mysql worked like a charm. I have attached the error log for
your consideration.
Thanks.
Ash
Application Internal Error - C:\MiniGUI\IDE\SAMPLES\DBF2MYSQL\Main.Exe
Terminated at: 2009.05.19 07:30:39
Info: Harbour MiniGUI 1.6 Extended Edition (Build 66) - 2009.04.29
Unrecoverable error 6005: Exception error:
Exception Code:C0000005
Exception Address:10020CAB
EAX:003A3D20 EBX:003A3D20 ECX:00000000 EDX:00000000
ESI:00AB29F8 EDI:00AB2920 EBP:00AF32B0
CS:EIP:001B:10020CAB SS:ESP:0023:0012EE38
DS:0023 ES:0023 FS:003B GS:0000
Flags:00010202
CS:EIP: FF 11 83 C4 04 C2 04 00 CC CC CC CC CC CC CC CC
SS:ESP: 003A3D20 0048AF57 003A3D20 00AB29F8 00AB2920 00AF32B0
00000000 00000CEA 00000000 00000000 00000CEA 00000000 0012EE94
005194E2 00000000 00516990
C stack:
EIP: EBP: Frame: OldEBP, RetAddr, Params...
10020CAB 00AF32B0 39343630 6F676F00 00000014 00000030 00000001
00AF32D8 00AB0000 00000000 00AF32F8 00ABAA9C
Modules:
0x00400000 0x00138000 C:\MiniGUI\IDE\SAMPLES\DBF2MYSQL\Main.Exe
0x7C900000 0x000B2000 C:\WINDOWS\system32\ntdll.dll
0x7C800000 0x000F6000 C:\WINDOWS\system32\kernel32.dll
0x10000000 0x001F4000 C:\MiniGUI\IDE\SAMPLES\DBF2MYSQL\LIBMYSQL.DLL
0x71AD0000 0x00009000 C:\WINDOWS\system32\WSOCK32.dll
0x71AB0000 0x00017000 C:\WINDOWS\system32\WS2_32.dll
0x77DD0000 0x0009B000 C:\WINDOWS\system32\ADVAPI32.dll
0x77E70000 0x00092000 C:\WINDOWS\system32\RPCRT4.dll
0x77FE0000 0x00011000 C:\WINDOWS\system32\Secur32.dll
0x77C10000 0x00058000 C:\WINDOWS\system32\msvcrt.dll
0x71AA0000 0x00008000 C:\WINDOWS\system32\WS2HELP.dll
0x75A70000 0x00021000 C:\WINDOWS\system32\MSVFW32.DLL
0x7E410000 0x00091000 C:\WINDOWS\system32\USER32.dll
0x77F10000 0x00049000 C:\WINDOWS\system32\GDI32.dll
0x76B40000 0x0002D000 C:\WINDOWS\system32\WINMM.dll
0x7C9C0000 0x00817000 C:\WINDOWS\system32\SHELL32.dll
0x77F60000 0x00076000 C:\WINDOWS\system32\SHLWAPI.dll
0x773D0000 0x00103000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-
Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\COMCTL32.dll
0x763B0000 0x00049000 C:\WINDOWS\system32\COMDLG32.DLL
0x76780000 0x00009000 C:\WINDOWS\system32\SHFOLDER.DLL
0x774E0000 0x0013D000 C:\WINDOWS\system32\OLE32.DLL
0x5EDD0000 0x00017000 C:\WINDOWS\system32\OLEPRO32.DLL
0x77120000 0x0008B000 C:\WINDOWS\system32\OLEAUT32.dll
0x76390000 0x0001D000 C:\WINDOWS\system32\IMM32.DLL
0x629C0000 0x00009000 C:\WINDOWS\system32\LPK.DLL
0x74D90000 0x0006B000 C:\WINDOWS\system32\USP10.dll
0x5AD70000 0x00038000 C:\WINDOWS\system32\uxtheme.dll
0x00F10000 0x0016F000 C:\WINDOWS\system32\nview.dll
0x76BF0000 0x0000B000 C:\WINDOWS\system32\PSAPI.DLL
0x77C00000 0x00008000 C:\WINDOWS\system32\VERSION.dll
0x77690000 0x00021000 C:\WINDOWS\system32\NTMARTA.DLL
0x71BF0000 0x00013000 C:\WINDOWS\system32\SAMLIB.dll
0x76F60000 0x0002C000 C:\WINDOWS\system32\WLDAP32.dll
0x74720000 0x0004C000 C:\WINDOWS\system32\MSCTF.dll
0x755C0000 0x0002E000 C:\WINDOWS\system32\msctfime.ime
0x01190000 0x00015000 C:\WINDOWS\system32\nvwddi.dll
0x71A50000 0x0003F000 C:\WINDOWS\System32\mswsock.dll
0x76F20000 0x00027000 C:\WINDOWS\system32\DNSAPI.dll
0x76FB0000 0x00008000 C:\WINDOWS\System32\winrnr.dll
0x76FC0000 0x00006000 C:\WINDOWS\system32\rasadhlp.dll
Called from MYSQL_REAL_CONNECT(0)
Called from TMYSQLSERVER:NEW(1364) in tmysql.prg
Called from SQL_CONNECT(48) in C:\MINIGUI\IDE\SAMPLES
\DBF2MY~1\Main.Prg
Called from (b)MYSQL_LOGIN(162) in C:\MINIGUI\IDE\SAMPLES
\DBF2MY~1\Main.Prg
Called from _DOCONTROLEVENTPROCEDURE(1611) in h_windows.prg
Called from EVENTS(1423) in h_events.prg
Called from _DOMESSAGELOOP(0)
Called from _ACTIVATEWINDOW(1329) in h_windows.prg
Called from MYSQL_LOGIN(27) in C:\MINIGUI\IDE\SAMPLES
\DBF2MY~1\Main.Prg
Called from (b)MAIN(4) in C:\MINIGUI\IDE\SAMPLES\DBF2MY~1\Main.Prg
Called from _PROCESSINITPROCEDURE(1454) in h_windows.prg
Called from _ACTIVATEWINDOW(1312) in h_windows.prg
Called from DOMETHOD(4653) in h_controlmisc.prg
Called from MAIN(18) in C:\MINIGUI\IDE\SAMPLES\DBF2MY~1\Main.Prg
This is the response from Grigori to Sudip's post on the same
matter :-
---- From Grigori - Start
Hi Sudip,
Take a look for the following function in source\HbMySql\mysql.c:
// Returns an SQL string with clipper value converted ie. Date() ->
"'YYYY-MM-DD'"
STATIC FUNCTION ClipValue2SQL( Value )
LOCAL cValue
SWITCH ValType( Value )
CASE "N"
cValue := hb_NToS( Value )
EXIT
CASE "D"
IF ! Empty( Value )
/* MySQL dates are like YYYY-MM-DD */
cValue := "'" + StrZero( Year( Value ), 4 ) + "-" + StrZero( Month
( Value ), 2 ) + "-" + StrZero( Day( Value ), 2 ) + "'"
ELSE
cValue := "''"
ENDIF
EXIT
CASE "C"
CASE "M"
IF Empty( Value )
cValue := "''"
ELSE
cValue := "'"
Value := mysql_escape_string( value )
cValue += value + "'"
ENDIF
EXIT
CASE "L"
cValue := iif( Value, "1", "0" )
EXIT
OTHERWISE
cValue := "''" // NOTE: Here we lose values we cannot convert
ENDSWITCH
RETURN cValue
Please be so kind to rename the function DATATOSQL() into
mysql_escape_string().
I hope that helps.
--
Regards,
Grigory
---- From Grigori - End
CCH
http://cch4clipper.blogspot.com
Hi,
I created Dbf2MySql with HMG official version, inspired by my HMG
+MySql guru, S. Rathinagiri. With HMG, you can use low level function
DATATOSQL(), but with Minigui Extended you have to add following lines
#ifndef __XHARBOUR__
#pragma BEGINDUMP
#define HB_OS_WIN_32_USED
#include "hbapi.h"
HB_FUNC_EXTERN( MYSQL_GET_SERVER_VERSION ); HB_FUNC
( SQLVERSION ) { HB_FUNC_EXEC( MYSQL_GET_SERVER_VERSION ); }
HB_FUNC_EXTERN( MYSQL_REAL_CONNECT ); HB_FUNC
( SQLCONNECT ) { HB_FUNC_EXEC( MYSQL_REAL_CONNECT ); }
HB_FUNC_EXTERN( MYSQL_CLOSE ); HB_FUNC
( SQLCLOSE ) { HB_FUNC_EXEC( MYSQL_CLOSE ); }
HB_FUNC_EXTERN( MYSQL_COMMIT ); HB_FUNC
( SQLCOMMIT ) { HB_FUNC_EXEC( MYSQL_COMMIT ); }
HB_FUNC_EXTERN( MYSQL_ROLLBACK ); HB_FUNC
( SQLROLLBACK ) { HB_FUNC_EXEC( MYSQL_ROLLBACK ); }
HB_FUNC_EXTERN( MYSQL_SELECT_DB ); HB_FUNC
( SQLSELECTD ) { HB_FUNC_EXEC( MYSQL_SELECT_DB ); }
HB_FUNC_EXTERN( MYSQL_QUERY ); HB_FUNC
( SQLQUERY ) { HB_FUNC_EXEC( MYSQL_QUERY ); }
HB_FUNC_EXTERN( MYSQL_STORE_RESULT ); HB_FUNC
( SQLSTORER ) { HB_FUNC_EXEC( MYSQL_STORE_RESULT ); }
HB_FUNC_EXTERN( MYSQL_USE_RESULT ); HB_FUNC
( SQLUSERES ) { HB_FUNC_EXEC( MYSQL_USE_RESULT ); }
HB_FUNC_EXTERN( MYSQL_FREE_RESULT ); HB_FUNC
( SQLFREER ) { HB_FUNC_EXEC( MYSQL_FREE_RESULT ); }
HB_FUNC_EXTERN( MYSQL_FETCH_ROW ); HB_FUNC
( SQLFETCHR ) { HB_FUNC_EXEC( MYSQL_FETCH_ROW ); }
HB_FUNC_EXTERN( MYSQL_DATA_SEEK ); HB_FUNC
( SQLDATAS ) { HB_FUNC_EXEC( MYSQL_DATA_SEEK ); }
HB_FUNC_EXTERN( MYSQL_NUM_ROWS ); HB_FUNC
( SQLNROWS ) { HB_FUNC_EXEC( MYSQL_NUM_ROWS ); }
HB_FUNC_EXTERN( MYSQL_FETCH_FIELD ); HB_FUNC
( SQLFETCHF ) { HB_FUNC_EXEC( MYSQL_FETCH_FIELD ); }
HB_FUNC_EXTERN( MYSQL_FIELD_SEEK ); HB_FUNC
( SQLFSEEK ) { HB_FUNC_EXEC( MYSQL_FIELD_SEEK ); }
HB_FUNC_EXTERN( MYSQL_NUM_FIELDS ); HB_FUNC
( SQLNUMFI ) { HB_FUNC_EXEC( MYSQL_NUM_FIELDS ); }
HB_FUNC_EXTERN( MYSQL_FIELD_COUNT ); HB_FUNC
( SQLFICOU ) { HB_FUNC_EXEC( MYSQL_FIELD_COUNT ); }
HB_FUNC_EXTERN( MYSQL_LIST_FIELDS ); HB_FUNC
( SQLLISTF ) { HB_FUNC_EXEC( MYSQL_LIST_FIELDS ); }
HB_FUNC_EXTERN( MYSQL_ERROR ); HB_FUNC
( SQLGETERR ) { HB_FUNC_EXEC( MYSQL_ERROR ); }
HB_FUNC_EXTERN( MYSQL_LIST_DBS ); HB_FUNC
( SQLLISTDB ) { HB_FUNC_EXEC( MYSQL_LIST_DBS ); }
HB_FUNC_EXTERN( MYSQL_LIST_TABLES ); HB_FUNC
( SQLLISTTBL ) { HB_FUNC_EXEC( MYSQL_LIST_TABLES ); }
HB_FUNC_EXTERN( MYSQL_AFFECTED_ROWS ); HB_FUNC
( SQLAFFROWS ) { HB_FUNC_EXEC( MYSQL_AFFECTED_ROWS ); }
HB_FUNC_EXTERN( MYSQL_GET_HOST_INFO ); HB_FUNC
( SQLHOSTINFO ) { HB_FUNC_EXEC( MYSQL_GET_HOST_INFO ); }
HB_FUNC_EXTERN( MYSQL_GET_SERVER_INFO ); HB_FUNC
( SQLSRVINFO ) { HB_FUNC_EXEC( MYSQL_GET_SERVER_INFO ); }
HB_FUNC_EXTERN( MYSQL_ESCAPE_STRING ); HB_FUNC
( DATATOSQL ) { HB_FUNC_EXEC( MYSQL_ESCAPE_STRING ); }
HB_FUNC_EXTERN( MYSQL_ESCAPE_STRING_FROM_FILE ); HB_FUNC
( FILETOSQLBINARY ) { HB_FUNC_EXEC( MYSQL_ESCAPE_STRING_FROM_FILE ); }
#pragma ENDDUMP
#endif
Or you can use Grigory Filatov's suggestion.
With best regards.
Sudip
I go this solution from \MiniGUI\SAMPLES\Advanced\MiniSql\MiniSql.prg
Regards.
Sudip