ADO RDD xHarbour

Re: ADO RDD xHarbour

Postby Enrico Maria Giordano » Wed Apr 08, 2015 9:43 pm

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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: ADO RDD xHarbour

Postby hmpaquito » Thu Apr 09, 2015 7:25 am

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)
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: ADO RDD xHarbour

Postby AHF » Thu Apr 09, 2015 7:58 am

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
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby Antonio Linares » Thu Apr 09, 2015 8:00 am

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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42120
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ADO RDD xHarbour

Postby AHF » Thu Apr 09, 2015 8:33 am

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  RUN


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?
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby hmpaquito » Thu Apr 09, 2015 9:28 am

ahf,

AHF wrote:
Code: Select all  Expand view  RUN


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.
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: ADO RDD xHarbour

Postby Enrico Maria Giordano » Thu Apr 09, 2015 10:02 am

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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: ADO RDD xHarbour

Postby AHF » Thu Apr 09, 2015 10:10 am

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?
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Thu Apr 09, 2015 10:12 am

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  RUN
DbCreate( <cDatabase> , ;
          <aStructure>, ;
         [<cDriver>]  , ;
         [<lNewArea>] , ;
         [<cAlias>]     ) --> NIL
 


Thank you.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby lucasdebeltran » Thu Apr 09, 2015 10:33 am

Sorry, it´s not working.

Test simple:

Code: Select all  Expand view  RUN

#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


 
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby AHF » Thu Apr 09, 2015 10:48 am

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?
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Thu Apr 09, 2015 6:08 pm

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 )
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby lucasdebeltran » Thu Apr 09, 2015 6:09 pm

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 )
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby AHF » Thu Apr 09, 2015 6:36 pm

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
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Thu Apr 09, 2015 6:42 pm

Code: Select all  Expand view  RUN
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
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], SantaCroya and 80 guests