Since the SQLRDD source codes have already been published, I have adapted this library for use with MiniGUI.
You can see the full source code of the example below.
Code: Select all
// SQLRDD
// test with MySQL
#include <minigui.ch>
#include "sqlrdd.ch"
#include <set.ch>
#define SQL_DBMS_NAME 17
#define SQL_DBMS_VER 18
// NOTE: the database must exist before runnning the test.
#define SERVER "localhost"
#define UID "root"
#define PWD "mypass"
#define DTB "test"
REQUEST SQLRDD
REQUEST SQLEX
REQUEST SR_MYSQL
PROCEDURE Main()
LOCAL nConnection
LOCAL n
LOCAL lDeleted := .F.
SET DATE FORMAT TO "yyyy-mm-dd"
SET DELETED ON
SET WINDOW MAIN OFF
rddSetDefault("SQLRDD")
nConnection := sr_AddConnection(CONNECT_MYSQL, "MySQL=" + SERVER + ";UID=" + UID + ";PWD=" + PWD + ";DTB=" + DTB)
IF nConnection < 0
alert("Connection error. See sqlerror.log for details.")
QUIT
ELSE
alert("Connected to : " + SR_GetConnectionInfo(, SQL_DBMS_NAME) + " " + SR_GetConnectionInfo(, SQL_DBMS_VER))
ENDIF
sr_StartLog(nConnection)
IF !sr_ExistTable("test")
dbCreate("test", {{"ID", "N", 10, 0}, ;
{"FIRST", "C", 30, 0}, ;
{"LAST", "C", 30, 0}, ;
{"AGE", "N", 3, 0}, ;
{"DATE", "D", 8, 0}, ;
{"MARRIED", "L", 1, 0}, ;
{"VALUE", "N", 12, 2}}, "SQLRDD")
ENDIF
USE test EXCLUSIVE VIA "SQLRDD"
IF !SR_ExistIndex("TESTID")
INDEX ON FIELD->ID TO TESTID
ENDIF
IF !SR_ExistIndex("TESTDATE")
INDEX ON FIELD->DATE TO TESTDATE
ENDIF
IF !SR_ExistIndex("TESTVAL")
INDEX ON FIELD->VALUE TO TESTVAL
ENDIF
SET INDEX TO TESTID, TESTDATE, TESTVAL
IF reccount() < 100
FOR n := 1 TO 100
APPEND BLANK
REPLACE ID WITH n
REPLACE FIRST WITH "FIRST" + hb_ntos(n)
REPLACE LAST WITH "LAST" + hb_ntos(n)
REPLACE AGE WITH n + 18
REPLACE DATE WITH date() - n
REPLACE MARRIED WITH iif(n / 2 == int(n / 2), .T., .F.)
REPLACE VALUE WITH n * 1000 / 100
NEXT n
ENDIF
GO TOP
EDIT EXTENDED
IF SET(_SET_DELETED)
SET DELETED OFF
SELECT TEST
GO TOP
DO WHILE !Eof()
IF Deleted()
lDeleted := .T.
EXIT
ELSE
dbSkip()
ENDIF
ENDDO
IF lDeleted
PACK
ENDIF
ENDIF
CLOSE DATABASE
sr_StopLog(nConnection)
sr_EndConnection(nConnection)
RETURN
https://github.com/xHarbour-org/xharbou ... our-SQLRDD
Changes required in your source code:
If your application already runs in xHarbour with DBF files, you will need to
make the following changes:
1 - Add database connection instructions. You can use the ones in
samples\SQLRDD folder. See samples\SQLRDD\connect.prg.
2 - Upload your DBF files to database. You may use samples\SQLRDD\dbf2sql.prg
for this.
3 - Add needed REQUESTs and include files in your main PRG:
#include "sqlrdd.ch" // SQLRDD Main include
#include "pgs.ch" // Needed if you plan to use native connection to Postgres
#include "mysql.ch" // Needed if you plan to use native connection to MySQL
#include "oracle.ch" // Needed if you plan to use native connection to Oracle
#include "firebird.ch" // Needed if you plan to use native connection to Firebird
REQUEST SQLRDD // SQLRDD should be linked in
REQUEST SR_ODBC // Needed if you plan to connect with ODBC
REQUEST SR_PGS // Needed if you plan to use native connection to Postgres
REQUEST SR_MYSQL // Needed if you plan to use native connection to MySQL
REQUEST SR_ORACLE // Needed if you plan to use native connection to Oracle
REQUEST SR_FIREBIRD // Needed if you plan to use native connection to Firebird
My question : is it interested to someone?
Your feedback is welcome.