Hi all,
I was wondering if anyone has used the Advantage RDD with HMG.
I noticed that there are some functions in the Harbour library ( ADSSetAOF() Create an Advantage Optimized Filter for example )
but I can't find any examples, either on teh Harbour site, or in the samples directory as delivered.
I used something similar ( but it might have been the Comix RDD... ) when I was developing professionally some years ago
and found it very useful for creating database Filters which made full use of indexes.
I really just need it for flexible reporting , but as I remember , it also allows some very fast queries.
Thanks
Steve
Advantage RDD
Moderator: Rathinagiri
Re: Advantage RDD
Hi Steve,spelman wrote:Hi all,
I was wondering if anyone has used the Advantage RDD with HMG.
I noticed that there are some functions in the Harbour library ( ADSSetAOF() Create an Advantage Optimized Filter for example )
but I can't find any examples, either on teh Harbour site, or in the samples directory as delivered.
I used something similar ( but it might have been the Comix RDD... ) when I was developing professionally some years ago
and found it very useful for creating database Filters which made full use of indexes.
I really just need it for flexible reporting , but as I remember , it also allows some very fast queries.
I don't use the Advantage RDD in my applications. But you may take a look for the working sample below:
Code: Select all
/*
* MINIGUI - Harbour Win32 GUI library
*
* Copyright 2002-2010 Roberto Lopez <harbourminigui@gmail.com>
* http://harbourminigui.googlepages.com/
*
* Demo of ADS Connection handling and Data Dictionaries
*
* Translate From xHarbour to Harbour MiniGui by Stefano Meli <stemeli@hotmail.com>
*/
#include "minigui.ch"
#include "Ads.ch"
FUNCTION Main()
RddRegister( "ADS", 1 )
RddSetDefault("ADT")
AdsSetServerType ( 7 )
Set Filetype To ADT
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 640 ;
HEIGHT 480 ;
TITLE "Advantage Database Server RDD Demo" ;
MAIN ;
NOMAXIMIZE ;
NOMINIMIZE ;
ON INIT OpenTable() ;
ON RELEASE Closetable() ;
BACKCOLOR GRAY
DEFINE BROWSE Browse_1
ROW 10
COL 100
WIDTH 1093
HEIGHT 900
HEADERS {'ID', 'Name', 'Address', 'City', 'Age'}
WIDTHS { 210, 230, 210, 210, 210}
WORKAREA custom
FIELDS { 'custom->id','custom->name','custom->address','custom->city','custom->age' }
JUSTIFY { BROWSE_JTFY_LEFT, BROWSE_JTFY_LEFT, BROWSE_JTFY_LEFT , BROWSE_JTFY_LEFT , BROWSE_JTFY_LEFT}
TOOLTIP 'Advantage Database Server RDD Demo'
VALUE 1
FONTNAME 'VERDANA'
FONTSIZE 9
VISIBLE .f.
END BROWSE
DEFINE MAIN MENU OF Win_1
POPUP "&File"
ITEM "&Browse test" ACTION (Win_1.Browse_1.Visible := .t. , Win_1.Browse_1.setfocus)
SEPARATOR
ITEM "E&xit" ACTION Win_1.Release
END POPUP
POPUP 'Help'
ITEM 'About' ACTION MsgInfo ("MiniGUI ADS RDD Demo")
END POPUP
END MENU
END WINDOW
DEFINE WINDOW Splash ;
AT 00,0 ;
WIDTH 500 HEIGHT 200 ;
TITLE '';
TOPMOST NOCAPTION ;
ON RELEASE Win_1.Maximize()
@ 55,45 LABEL Label_1 ;
WIDTH 400 HEIGHT 80 ;
VALUE PadC('Please Wait ',60) + CRLF + ;
PadC ('Now Create a Data dictionary ', 50) ;
FONT 'Arial' SIZE 16
END WINDOW
Win_1.Browse_1.Hide
CENTER WINDOW Splash
CENTER WINDOW Win_1
ACTIVATE WINDOW Splash, Win_1
RETURN Nil
/*-----------------------------------------------------------------------------*/
Procedure OpenTable()
/*-----------------------------------------------------------------------------*/
local cErr
local aStru := {{ "ID", "A", 1, 0}, {"Name", "C", 50, 0}, {"address", "C", 50, 0}, {"city", "C", 30, 0}, {"Age", "n", 3, 0}}
local lIsDict := .f.
local n
local hConnection1
fErase("harbour.add")
fErase("harbour.ai")
fErase("harbour.am")
fErase("Table1.adt")
fErase("Table1.adi")
fErase("Table2.adt")
fErase("Table2.adi")
// now Create a Data dictionary and the files if not exist
IF !File("harbour.add")
ADSDDCREATE("harbour.add",, "harbour ADS demo for data dictionary")
// This also creates an Administrative Handle that is set as the default
// MsgInfo("Default connection is now this admin handle:" + STR(adsConnection()))
AdsDisconnect() // disconnect current default. If you wanted to retain this connection for later, you could use
// hAdminCon := adsConnection(0)
// This get/set call would return the current connection, then set it to 0
// MsgInfo("Default connection is now this handle (zero):" + STR(adsConnection()))
// now create two free tables with same structure
DbCreate("Table1", aStru)
DbCreate("Table2", aStru)
//now create an index
USE table1 new
INDEX ON id TAG codigo
USE
USE table2 new
INDEX ON id TAG codigo
USE
ENDIF
// now the magic
IF adsConnect60("harbour.add", 7/* All types of connection*/, "ADSSYS", "", , @hConnection1 )
// The connection handle to harbour.add is now stored in hConnection1,
// and this is now the default connection
// Add one user
AdsDDCreateUser(, "Luiz", "papael", "This is user Luiz")
// "Add the tables"
AdsDDaddTable("Table1", "table1.adt", "table1.adi")
IF ! AdsDDaddTable("Customer data", "table2.adt", "table2.adi")
// notice the "long table name" for file Table2.adt.
// Later open it with "Customer data" as the table name
MsgExclamation ("Error adding table:" + (adsGetLastError(@cErr))+ (cErr) )
ENDIF
ELSE
MsgExclamation ("Error connecting to harbour.add!")
ENDIF
AdsDisconnect(hConnection1)
hConnection1 := nil // you should always reset a variable holding a handle that is no longer valid
AdsConnect60("harbour.add", 7/* All types of connection*/, "Luiz", "papael", , @hConnection1)
FOR n := 1 TO 100
IF AdsCreateSqlStatement("Data2", 3)
AdsExecuteSqlDirect(" insert into Table1( name,address,city,age) VALUES( '" + strzero(n)+"','"+strzero(n)+"','"+strzero(n)+"'," +str(n)+ ")" )
USE
ENDIF
NEXT
FOR n := 1 TO 100
IF AdsCreateSqlStatement("Data1", 3)
AdsExecuteSqlDirect(" insert into " +'"Customer Data"'+"( name,address,city,age) VALUES( '"+ strzero(n)+"','"+strzero(n)+"','"+strzero(n)+"'," +str(n)+")" )
USE
ENDIF
NEXT
Splash.Release
DbUseArea(.t.,, "Customer data", "custom", .t., .f.)
Return Nil
/*-----------------------------------------------------------------------------*/
PROCEDURE CloseTable()
/*-----------------------------------------------------------------------------*/
CLOSE ALL
RETURN NilKind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Re: Advantage RDD
Excellent - Thankyou for the fast reply Grigory