New AdoRDD (free)
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
GetValue
This change for correct GetValue if database is empty
STATIC FUNCTION ADO_GETVALUE( nWA, nField, xValue )
LOCAL aWData := USRRDD_AREADATA( nWA )
LOCAL oADO := USRRDD_AREADATA( nWA )[ 1 ]
IF aWData[ 3 ]
xValue := ""
ELSE
IF oADO:BOF .AND. oADO:EOF
xValue := NIL
ELSE
xValue := oADO:Fields( nField - 1 ):Value
ENDIF
ENDIF
RETURN SUCCESS
STATIC FUNCTION ADO_GETVALUE( nWA, nField, xValue )
LOCAL aWData := USRRDD_AREADATA( nWA )
LOCAL oADO := USRRDD_AREADATA( nWA )[ 1 ]
IF aWData[ 3 ]
xValue := ""
ELSE
IF oADO:BOF .AND. oADO:EOF
xValue := NIL
ELSE
xValue := oADO:Fields( nField - 1 ):Value
ENDIF
ENDIF
RETURN SUCCESS
dbAppend
STATIC FUNCTION ADO_APPEND( nWA, lUnLockAll )
local oADO := USRRDD_AREADATA( nWA )[ 1 ]
oADO:AddNew()
TRY
oADO:Update() // keep it here, or there is an ADO error
CATCH
END
RETURN SUCCESS
Must add code TRY/CATCH if oADO:Update() create error
local oADO := USRRDD_AREADATA( nWA )[ 1 ]
oADO:AddNew()
TRY
oADO:Update() // keep it here, or there is an ADO error
CATCH
END
RETURN SUCCESS
Must add code TRY/CATCH if oADO:Update() create error
dbCreate
// Creating fields for new DBF - dbCreate() in current workarea
STATIC FUNCTION ADO_CREATEFIELDS( nWA, aStruct )
LOCAL aWData := USRRDD_AREADATA( nWA )
aWData[ 1 ] := { ;
NIL ,; // DATABASE_FILENAME
{} ,; // DATABASE_RECORDS
{} ,; // DATABASE_RECINFO
0 ,; // DATABASE_OPENNUMBER
FALSE ,; // DATABASE_LOCKED
aStruct; // DATABASE_STRUCT
}
RETURN SUCCESS
STATIC FUNCTION ADO_CREATE( nWA, aOpenInfo )
LOCAL aWData := USRRDD_AREADATA( nWA )
LOCAL aRData := USRRDD_RDDDATA( USRRDD_ID( nWA ) )
LOCAL aField, oError, cName
LOCAL cFullName, aDBFData
LOCAL cCMD := "CREATE TABLE "
Local aStruct, I
/* getting database infos from current workarea */
aDBFData := aWData[ 1 ]
aStruct := aWData[ 1 ][ 6 ]
/* setting in uppercase chars to avoid differences */
cFullName := Upper( aOpenInfo[ UR_OI_NAME ] )
// When there is no ALIAS we will create new one using file name
IF aOpenInfo[ UR_OI_ALIAS ] == NIL
HB_FNAMESPLIT( cFullName, , @cName )
aOpenInfo[ UR_OI_ALIAS ] := cName
ENDIF
// Check if database is already present in memory slots
IF !( cFullName IN aRData )
// Setting file attribs
aDBFData[ 1 ] := cFullName
aDBFData[ 5 ] := TRUE /* I need Exclusive mode in creation */
cCMD += cFullName+" ( "
FOR I=1 TO LEN( aStruct )
cCMD += aStruct[i,1]+" "
IF aStruct[i,2]=="C"
cCMD += "VARCHAR("+ALLTRIM(STR(aStruct[i,3]))+")"
ELSEIF aStruct[i,2]=="M"
cCMD += "VARCHAR("+ALLTRIM(STR(aStruct[i,3]))+")"
ELSEIF aStruct[i,2]=="N"
cCMD += "NUMERIC("+ALLTRIM(STR(aStruct[i,3]))+","+ALLTRIM(STR(aStruct[i,4]))+" )"
ELSEIF aStruct[i,2]=="D"
cCMD += "DATE"
ENDIF
IF i==LEN(aStruct)
cCMD += " )"
ELSE
cCMD += ", "
ENDIF
NEXT I
if s_cConnection != NIL
TRY
s_cConnection:Execute( "DROP TABLE "+cFullName )
CATCH
END
TraceLog( cCMD )
s_cConnection:Execute( cCMD )
endif
// Adding new database in RDD memory slots using filename as key
ELSE
// ERROR: database already exists
oError := ErrorNew()
oError:GenCode := EG_CREATE
oError:SubCode := 1004 // EDBF_CREATE_DBF
oError:Description := HB_LANGERRMSG( EG_CREATE ) + " (" + ;
HB_LANGERRMSG( EG_UNSUPPORTED ) + " - database already exists)"
oError:FileName := aOpenInfo[ UR_OI_NAME ]
oError:CanDefault := .T.
UR_SUPER_ERROR( nWA, oError )
RETURN FAILURE
ENDIF
// Set WorkArea Info
aWData[ 3 ] := aOpenInfo // Put open informations
// increase open number
aDBFData[ 4 ]++
RETURN SUCCESS
Add this code in ADORDD.PRG
aMyFunc[ UR_CREATE ] := ( @ADO_CREATE() )
aMyFunc[ UR_CREATEFIELDS ] := ( @ADO_CREATEFIELDS() )
Add this two line into FUNCTION ADORDD_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID )
Test it !
dbCreate is work
STATIC FUNCTION ADO_CREATEFIELDS( nWA, aStruct )
LOCAL aWData := USRRDD_AREADATA( nWA )
aWData[ 1 ] := { ;
NIL ,; // DATABASE_FILENAME
{} ,; // DATABASE_RECORDS
{} ,; // DATABASE_RECINFO
0 ,; // DATABASE_OPENNUMBER
FALSE ,; // DATABASE_LOCKED
aStruct; // DATABASE_STRUCT
}
RETURN SUCCESS
STATIC FUNCTION ADO_CREATE( nWA, aOpenInfo )
LOCAL aWData := USRRDD_AREADATA( nWA )
LOCAL aRData := USRRDD_RDDDATA( USRRDD_ID( nWA ) )
LOCAL aField, oError, cName
LOCAL cFullName, aDBFData
LOCAL cCMD := "CREATE TABLE "
Local aStruct, I
/* getting database infos from current workarea */
aDBFData := aWData[ 1 ]
aStruct := aWData[ 1 ][ 6 ]
/* setting in uppercase chars to avoid differences */
cFullName := Upper( aOpenInfo[ UR_OI_NAME ] )
// When there is no ALIAS we will create new one using file name
IF aOpenInfo[ UR_OI_ALIAS ] == NIL
HB_FNAMESPLIT( cFullName, , @cName )
aOpenInfo[ UR_OI_ALIAS ] := cName
ENDIF
// Check if database is already present in memory slots
IF !( cFullName IN aRData )
// Setting file attribs
aDBFData[ 1 ] := cFullName
aDBFData[ 5 ] := TRUE /* I need Exclusive mode in creation */
cCMD += cFullName+" ( "
FOR I=1 TO LEN( aStruct )
cCMD += aStruct[i,1]+" "
IF aStruct[i,2]=="C"
cCMD += "VARCHAR("+ALLTRIM(STR(aStruct[i,3]))+")"
ELSEIF aStruct[i,2]=="M"
cCMD += "VARCHAR("+ALLTRIM(STR(aStruct[i,3]))+")"
ELSEIF aStruct[i,2]=="N"
cCMD += "NUMERIC("+ALLTRIM(STR(aStruct[i,3]))+","+ALLTRIM(STR(aStruct[i,4]))+" )"
ELSEIF aStruct[i,2]=="D"
cCMD += "DATE"
ENDIF
IF i==LEN(aStruct)
cCMD += " )"
ELSE
cCMD += ", "
ENDIF
NEXT I
if s_cConnection != NIL
TRY
s_cConnection:Execute( "DROP TABLE "+cFullName )
CATCH
END
TraceLog( cCMD )
s_cConnection:Execute( cCMD )
endif
// Adding new database in RDD memory slots using filename as key
ELSE
// ERROR: database already exists
oError := ErrorNew()
oError:GenCode := EG_CREATE
oError:SubCode := 1004 // EDBF_CREATE_DBF
oError:Description := HB_LANGERRMSG( EG_CREATE ) + " (" + ;
HB_LANGERRMSG( EG_UNSUPPORTED ) + " - database already exists)"
oError:FileName := aOpenInfo[ UR_OI_NAME ]
oError:CanDefault := .T.
UR_SUPER_ERROR( nWA, oError )
RETURN FAILURE
ENDIF
// Set WorkArea Info
aWData[ 3 ] := aOpenInfo // Put open informations
// increase open number
aDBFData[ 4 ]++
RETURN SUCCESS
Add this code in ADORDD.PRG
aMyFunc[ UR_CREATE ] := ( @ADO_CREATE() )
aMyFunc[ UR_CREATEFIELDS ] := ( @ADO_CREATEFIELDS() )
Add this two line into FUNCTION ADORDD_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID )
Test it !
dbCreate is work
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Code: Select all
2007-05-01 22:53 UTC+0100 Antonio Linares (alinares@fivetechsoft.com)
* contrib/adordd/adordd.prg
* DbCreate() implementation just for Microsoft Access
+ contrib/adordd/access2.prg
* DbCreate() sample with Microsoft Access
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Our idea to implement DbCreate() for any ADO database engine is to use it this way:
Code: Select all
DbCreate( "test00;test;MYSQL;www.freesql.org;myuser;mypass",;
{ { "FIRST", "C", 10, 0 },;
{ "LAST", "C", 10, 0 },;
{ "AGE", "N", 8, 0 } }, "ADORDD" )
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Code: Select all
2007-05-05 10:28 UTC+0100 Antonio Linares (alinares@fivetechsoft.com)
* contrib/adordd/adordd.prg
* Improved formatting and xharbour compatibility
Erro AdoRdd
Que error puede ser ese.
rror: Unresolved external '_hb_vmProcessSymbolsEx' referenced from T:\FWH_28\XHARBOUR\LIB\ADORDD.LIB|adordd
rror: Unresolved external '_hb_vmProcessSymbolsEx' referenced from T:\FWH_28\XHARBOUR\LIB\ADORDD.LIB|adordd
S.A.Oliveira
Lins-SP - Brasil
FWH 10.9, PellesC,MySql
Lins-SP - Brasil
FWH 10.9, PellesC,MySql
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Code: Select all
2007-05-06 11:42 UTC+0100 Antonio Linares (alinares@fivetechsoft.com)
* contrib/adordd/adordd.ch
* New define added
* contrib/adordd/adordd.prg
* SET RELATION implementation
AdoRdd
Sou novo e estou apanhando um bocado.
Error: Unresolved external '_hb_itemMove' referenced from T:\FWH_28\XHARBOUR\LIB\USRRDD.LIB|usrrdd
Error: Unresolved external '_hb_itemMove' referenced from T:\FWH_28\XHARBOUR\LIB\USRRDD.LIB|usrrdd
S.A.Oliveira
Lins-SP - Brasil
FWH 10.9, PellesC,MySql
Lins-SP - Brasil
FWH 10.9, PellesC,MySql
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
AdoRdd
Ok, com bancos .MDB.
Com banco MySql:
Error description: Error ADODB.Connection/16389 E_FAIL: OPEN
Args: [ 1] = C DRIVER={MySQL ODBC 3.51 Driver};server=192.168.0.254;database=ARQPRO;uid=newuser;pwd=newsenha
Stack Calls
===========
Called from: win32ole.prg => TOLEAUTO:OPEN(0)
Called from: => ADO_OPEN(221)
Called from: => DBUSEAREA(0)
Called from: teste.prg => MAIN(9)
Com banco MySql:
Error description: Error ADODB.Connection/16389 E_FAIL: OPEN
Args: [ 1] = C DRIVER={MySQL ODBC 3.51 Driver};server=192.168.0.254;database=ARQPRO;uid=newuser;pwd=newsenha
Stack Calls
===========
Called from: win32ole.prg => TOLEAUTO:OPEN(0)
Called from: => ADO_OPEN(221)
Called from: => DBUSEAREA(0)
Called from: teste.prg => MAIN(9)
S.A.Oliveira
Lins-SP - Brasil
FWH 10.9, PellesC,MySql
Lins-SP - Brasil
FWH 10.9, PellesC,MySql