Page 5 of 14

PostPosted: Tue May 01, 2007 9:45 am
by Antonio Linares
Srdjan,

All suggestions are welcome :-)

GetValue

PostPosted: Tue May 01, 2007 2:56 pm
by digicad
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

dbAppend

PostPosted: Tue May 01, 2007 4:29 pm
by digicad
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

dbCreate

PostPosted: Tue May 01, 2007 4:56 pm
by digicad
// 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 :)

PostPosted: Tue May 01, 2007 6:15 pm
by Antonio Linares
Srdjan,

We are going to implement it in a different way.

We plan to publish it today :-)

ADORDD

PostPosted: Tue May 01, 2007 6:20 pm
by digicad
OK :)

PostPosted: Tue May 01, 2007 9:00 pm
by Antonio Linares
Code: Select all  Expand view
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


www.fivetechsoft.com/files/adordd.zip

PostPosted: Tue May 01, 2007 9:54 pm
by Antonio Linares
Our idea to implement DbCreate() for any ADO database engine is to use it this way:
Code: Select all  Expand view
   DbCreate( "test00;test;MYSQL;www.freesql.org;myuser;mypass",;
             { { "FIRST", "C", 10, 0 },;
               { "LAST",  "C", 10, 0 },;
               { "AGE",   "N",  8, 0 } }, "ADORDD" )

PostPosted: Sat May 05, 2007 8:32 am
by Antonio Linares
Code: Select all  Expand view
2007-05-05 10:28 UTC+0100 Antonio Linares (alinares@fivetechsoft.com)
   * contrib/adordd/adordd.prg
     * Improved formatting and xharbour compatibility


www.fivetechsoft.com/files/adordd.zip

Erro AdoRdd

PostPosted: Sun May 06, 2007 12:32 am
by Personal
Que error puede ser ese.

rror: Unresolved external '_hb_vmProcessSymbolsEx' referenced from T:\FWH_28\XHARBOUR\LIB\ADORDD.LIB|adordd

PostPosted: Sun May 06, 2007 8:46 pm
by Antonio Linares
You have to build the ADORDD.lib using your Harbour/xHarbour build

PostPosted: Sun May 06, 2007 8:47 pm
by Antonio Linares
Code: Select all  Expand view
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


www.fivetechsoft.com/files/adordd.zip

AdoRdd

PostPosted: Sun May 06, 2007 10:34 pm
by Personal
Sou novo e estou apanhando um bocado.

Error: Unresolved external '_hb_itemMove' referenced from T:\FWH_28\XHARBOUR\LIB\USRRDD.LIB|usrrdd

PostPosted: Sun May 06, 2007 10:56 pm
by Antonio Linares

AdoRdd

PostPosted: Mon May 07, 2007 12:24 am
by Personal
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)