Page 25 of 70

Re: ADO RDD xHarbour

PostPosted: Wed Apr 08, 2015 9:43 pm
by Enrico Maria Giordano
Antonio,

AHF wrote:Enrico,

Ok thats what adordd expects.

Do you have the same field name in every table?


This is your choice. I use "ID" but you may prefer "something" + tablename so you won't have problems with the queries.

EMG

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 7:25 am
by hmpaquito
This is your choice. I use "ID" but you may prefer "something" + tablename so you won't have problems with the queries.


Which problems ?
IMHO Its seems what same field for all tables is a more clear solution. (hbrecno)

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 7:58 am
by AHF
hmpaquito,

The problem is that there might be users with some "id" autoinc field already in some tables thus adordd should use it and not force them to create a new field.

Antonio,

Do you agree ? Lets give the option to the programmer?

Either a default field name for all tables or a diferent field for each table

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 8:00 am
by Antonio Linares
Antonio,

Maybe the solution is to check if such field with those properties exist and if not, then create hbrecno.

Not sure if both can co exist with no problems.

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 8:33 am
by AHF
Antonio,

I think adordd should not be able to create new tables.
From my experience in our clients we cannot. Thats to DBadmin.
Sometimes other apps use the same DB and one cannot alter any struct indexes whatever.
Besides that there are functions already for that propose so users can work directly with it.

My approach for adordd would be place in the start of app :

Code: Select all  Expand view


SET ADO TABLES INDEX LIST TO { {"SECTOR",{"SECTOR","SECTORES"} },;
 {"CCLIENTE",{"COD_CLI","CODCLIENTE"},;
   {"CLIENTE","NOME"},{"CTEMP2","VENDEDOR,SECTOR,CODCLIENTE"} } }
 
 SET ADO TEMPORAY NAMES INDEX LIST TO {"TMP","TEMP"}

 SET ADO FIELD RECNO TABLES LIST TO {{"ENCCLIST","ID"},{"FACTURAS","IDRECNO"}}

 SET ADO DEFAULT FIELD  RECNO TO  "HBRECNO"

 


I Think this is flexible enough to allow all situations and not assuming wrong fields.

Agree?

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 9:28 am
by hmpaquito
ahf,

AHF wrote:
Code: Select all  Expand view


SET ADO TABLES INDEX LIST TO { {"SECTOR",{"SECTOR","SECTORES"} },;
 {"CCLIENTE",{"COD_CLI","CODCLIENTE"},;
   {"CLIENTE","NOME"},{"CTEMP2","VENDEDOR,SECTOR,CODCLIENTE"} } }
 
 SET ADO FIELD RECNO TABLES LIST TO {{"ENCCLIST","ID"},{"FACTURAS","IDRECNO"}}

 SET ADO DEFAULT FIELD  RECNO TO  "HBRECNO"

 





I think these global variables or sets should be configured by database and not by application. An application can open multiple databases.

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 10:02 am
by Enrico Maria Giordano
Antonio,

hmpaquito wrote:
This is your choice. I use "ID" but you may prefer "something" + tablename so you won't have problems with the queries.


Which problems ?
IMHO Its seems what same field for all tables is a more clear solution. (hbrecno)


Problem with joins. In a join you can't have field with same name from different tables so you have to use AS clause.

EMG

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 10:10 am
by AHF
Enrico,

Thats true. But thats to the DB admin and the app developer to define.

adordd should cover any situation so I think the best way is to let to the developer define those in the previous sets.

Wont you agree or do you have a better way?

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 10:12 am
by lucasdebeltran
Hello,

I have not been able to test latter versions due to a lack of time.

I think we should use always HBRECNO, as it´s not a common field name like ID, which is the one I use. In fact, SQLRDD from xHarbour.com uses a private field for such purpouses.

I also think ADORDD should be able to create "tables", with dbcreate.

In fact, to achieve the equal behaviour as DBFCDX, index auto open should be present.

And the user should only do two little changes:

Define at FUNCTION ListIndex() the indexes. They will be opened with SET INDEX TO INDEX1, INDEX2, INDEX3... if SET AUTOPEN is OFF.

Define globally with a SetUp ADORDD function the RBDM type (Access, MSSQL, MySQL..), the server, the user name, the password to connect and the database name.

That´s all.

DbCreate now needs to pass some extra parameeters with ;. Once the above function is created, DBcreate should work as ordinary in DBFCDX:

Code: Select all  Expand view
DbCreate( <cDatabase> , ;
          <aStructure>, ;
         [<cDriver>]  , ;
         [<lNewArea>] , ;
         [<cAlias>]     ) --> NIL
 


Thank you.

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 10:33 am
by lucasdebeltran
Sorry, it´s not working.

Test simple:

Code: Select all  Expand view

#include "fivewin.ch"

#include "adordd\adordd.ch"
#include "adordd\adordd.prg"


REQUEST ADORDD

function Main()

   local aArray := {}


   RDDSETDEFAULT(   "ADORDD"   )


   IF !FILE(   "test2.mdb"   )

      DbCreate( "test2.mdb;table1", { { "FIRST",   "C", 30, 0 },;
                                      { "LAST",    "C", 30, 0 },;
                                      { "AGE",     "N",  8, 0 } }, "ADORDD" )
   ENDIF


   USE test2.mdb VIA "ADORDD" TABLE "table1" NEW ALIAS "TEST2"

   XBROWSER FASTEDIT


   APPEND BLANK
   test2->First   := "HOMER si no Homer"
   test2->Last    := "Simpson"
   test2->Age     := 45

   APPEND BLANK
   test2->First   := "aaa Lara"
   test2->Last    := "Croft si no"
   test2->Age     := 32


   GO TOP

   xBrowse()
   DbCloseAll()




return nil


 

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 10:48 am
by AHF
Lucas,

I think we should use always HBRECNO, as it´s not a common field name like ID, which is the one I use. In fact, SQLRDD from xHarbour.com uses a private field for such purpouses.


I choose to give this to the developer. Please see my previous post about SET...

I also think ADORDD should be able to create "tables", with dbcreate.


You can.

In fact, to achieve the equal behaviour as DBFCDX, index auto open should be present.


It is working.

Define at FUNCTION ListIndex() the indexes. They will be opened with SET INDEX TO INDEX1, INDEX2, INDEX3... if SET AUTOPEN is OFF.


AUTO OPEN and SET AUTOORDER should be working.

Define globally with a SetUp ADORDD function the RBDM type (Access, MSSQL, MySQL..), the server, the user name, the password to connect and the database name.


Can you supply code?

DbCreate now needs to pass some extra parameeters with ;. Once the above function is created, DBcreate should work as ordinary in DBFCDX:


What do you mean?

Sorry, it´s not working.

Test simple:

Code:

#include "fivewin.ch"

#include "adordd\adordd.ch"
#include "adordd\adordd.prg"


Whats the error ? and Whats the version?

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 6:08 pm
by lucasdebeltran
Hello,

XBROWSER FASTEDIT

Error description: Error BASE/1068 Argument error: array access
Args:
[ 1] = U
[ 2] = N 1

Stack Calls
===========
Called from: lucas.prg => (b)ADO_INDEXAUTOOPEN( 1269 )
Called from: => ASCAN( 0 )
Called from: lucas.prg => ADO_INDEXAUTOOPEN( 1269 )
Called from: lucas.prg => ADO_OPEN( 382 )
Called from: => DBUSEAREA( 0 )
Called from: lucas.prg => MAIN( 31 )

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 6:09 pm
by lucasdebeltran
Next, I SET AUTOPEN OFF:


Error description: Error BASE/1075 Argument error: >
Args:
[ 1] = N 1
[ 2] = C

Stack Calls
===========
Called from: .\source\classes\DATABASE.PRG => ORDERTAGINFO( 1258 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:SETRDD( 4135 )
Called from: .\source\classes\XBROWSE.PRG => XBRWSETDATASOURCE( 13030 )
Called from: .\source\function\XBROWSER.PRG => XBROWSE( 112 )
Called from: lucas.prg => MAIN( 35 )

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 6:36 pm
by AHF
Lucas,

I dont know the error. Have you check if index table and names are correct
Was it working in a previous version?

Called from: .\source\classes\DATABASE.PRG => ORDERTAGINFO( 1258 )

What is that function line doing ?

I hope to post soon today new version that seems to have all these resolved

Re: ADO RDD xHarbour

PostPosted: Thu Apr 09, 2015 6:42 pm
by lucasdebeltran
Code: Select all  Expand view
function OrderTagInfo( aStruct, nCol )

   local nFor, nAt, i, nOrders, aTokens, lCond, aCond, aPos

   DEFAULT aStruct      := DbStruct(), ;
           nCol         := DBS_TAG

   aCond       := Array( Len( aStruct ) ); AFill( aCond, .f. )
   aPos        := Array( Len( aStruct ) ); AFill( aPos,   0  )

   for nFor := 1 to Len( aStruct )
      if Len( aStruct[ nFor ] ) < nCol
         ASize( aStruct[ nFor ], nCol )
      endif
   next nFor

   nOrders     := OrdCount()
   for nFor := 1 to nOrders

      lCond    := ! Empty( OrdFor() )

      aTokens  := GetTokens( OrdKey( nFor ) )
      for i := 1 to Len( aTokens )
         nAt   := AScan( aStruct, { |aFld| aFld[ 1 ] == aTokens[ i ] } )
         if nAt > 0
            if aStruct[ nAt ][ nCol ] == nil .or. ( aCond[ nAt ] .and. ! lCond ) .or. ;
                                                  ( aPos[  nAt ] > i )
               aStruct[ nAt ][ nCol ] := Upper( OrdName( nFor ) )
               aCond[ nAt ]   := lCond
               aPos[  nAt ]   := i
            endif
            EXIT
         endif
      next i

   next nFor

return aStruct
 



Error is at OrdCount():

nOrders := OrdCount()
for nFor := 1 to nOrders