Author | Topic: Using ADS to work with DBF/DBT/NTX and Fox DBF/FPT/CDX in same application | |
---|---|---|
Jonathan Leeming | Using ADS to work with DBF/DBT/NTX and Fox DBF/FPT/CDX in same application on Tue, 17 Oct 2017 16:46:16 -0600 Hi, I currently use DBF/DBT/NTX with ADS in my application but would also like to connect to Fox DBF/FPT/CDX. To successfully use DBF/DBT/NTX I use... IF DbeLoad( "ADSDBE" ) DbeSetDefault( "ADSDBE" ) cDataDrive := "K:" DbeInfo( COMPONENT_DATA,ADSDBE_LOCK_MODE,ADSDBE_COMPATIBLE_LOCKING ) DbeInfo( COMPONENT_DATA, ADSDBE_DICTIONARY_DATA, .F. ) oSession := dacSession():New( "ADSDBE", cDataDrive) IF .NOT. (sAXS := oSession:isConnected( )) lDbeSysFail := .T. ENDIF ELSE lDbeSysFail := .T. ENDIF I then added the following thinking that I would need to have a second dacSession... oFoxSession := dacSession():New( "ADSDBE", cDataDrive ) IF oFoxSession:isConnected() DBEINFO( COMPONENT_DATA, ADSDBE_TBL_MODE, ADSDBE_CDX ) DBEINFO( COMPONENT_ORDER, ADSDBE_INDEX_EXT, "CDX" ) SET DEFAULT TO C:\fcdb USE Parts NEW SHARED <---- Dies without error here!!! INDEX ON PartName TAG PartName TO Parts ENDIF So my questions are... 1) Can it be done? 2) Would someone care to enlighten me? Thanks... Jonathan | |
Jonathan Leeming | Re: Using ADS to work with DBF/DBT/NTX and Fox DBF/FPT/CDX in same application on Wed, 18 Oct 2017 14:15:33 -0600 Hi, I continued to play with this and now have it working but am wondering if there is still a better way... Currently I... DbeLoad( "ADSDBE", .F.) * Create a single oSession and use for both DBF/DBT/NTX & DBF/FTP/CDX oSession := dacSession():New( "ADSDBE", cDrive ) oSession:SetDefault(.T.) Then before I access an DBF/DBT/NTX I call SetClp() FUNCTION SetClp() DbeInfo( COMPONENT_DATA, ADSDBE_TBL_MODE, ADSDBE_NTX) DbeInfo( COMPONENT_ORDER, ADSDBE_INDEX_EXT, "NTX") RETURN NIL And before I access DBF/FTP/CDX I call SetFox() FUNCTION SetFox() DbeInfo( COMPONENT_DATA, ADSDBE_TBL_MODE, ADSDBE_CDX) DbeInfo( COMPONENT_ORDER, ADSDBE_INDEX_EXT, "CDX") RETURN NIL Which appears to work but I'm still wondering if there is a better way. I omitted some error checking / notifications and also think that I might have some sort of flag set in SetClp() / SetFox() which could be checked and skip calling either of the SetClp() / SetFox() if that is already the current setting. Thanks... Jonathan On 10/17/2017 4:46 PM, Jonathan Leeming wrote: > So my questions are... > > 1) Can it be done? > 2) Would someone care to enlighten me? > > Thanks... Jonathan > | |
Andreas Gehrs-Pahl | Re: Using ADS to work with DBF/DBT/NTX and Fox DBF/FPT/CDX in same application on Thu, 19 Oct 2017 07:17:06 -0400 Jonathan, >Then before I access an DBF/DBT/NTX I call SetClp() >And before I access DBF/FTP/CDX I call SetFox() >Which appears to work but I'm still wondering if there is a better way. You only need to do this before opening (or creating) a database -- before the call to DbUseArea() / DbCreate(). The DBO (Database Object) that manages each database keeps track of the settings, so you don't need to call this code again, while the table is open. If you meant that with "access", then you are actually doing that already, so never mind. If you meant things like DbSkip() or DbSeek(), etc. with "access", then you can simplify your code and remove any extra calls to your SetXxx() functions. Hope that helps, Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [F]: https://www.facebook.com/AbsoluteSoftwareLLC | |
Jonathan Leeming | Re: Using ADS to work with DBF/DBT/NTX and Fox DBF/FPT/CDX in same application on Thu, 19 Oct 2017 08:43:09 -0600 On 10/19/2017 5:17 AM, Andreas Gehrs-Pahl wrote: > Jonathan, > >> Then before I access an DBF/DBT/NTX I call SetClp() >> And before I access DBF/FTP/CDX I call SetFox() > >> Which appears to work but I'm still wondering if there is a better way. > > You only need to do this before opening (or creating) a database -- before > the call to DbUseArea() / DbCreate(). The DBO (Database Object) that manages > each database keeps track of the settings, so you don't need to call this > code again, while the table is open. If you meant that with "access", then > you are actually doing that already, so never mind. If you meant things like > DbSkip() or DbSeek(), etc. with "access", then you can simplify your code > and remove any extra calls to your SetXxx() functions. > > Hope that helps, > > Andreas > Thanks... Helps "Big Time!" as I was using the word "access" in the broadest sense. Having to only set DbeInfo() before DBUseArea() / DBCreate() will simplify the switching between the two considerably as I have one function for my entire application that handles DBUseArea() and another one that handles all my temp work file DBCreate(). Now my main focus will be on the index files. It's my understanding that having certain functions within an index may give different results in the CDX world compared to NTX. eg: "ServiceID+ProgramID+ServForm+STR(DESCEND(StartDate))" Although the DBF/DBT/NTX world has been working well I'm certainly hoping to gain some efficiencies by having more efficient memo files capable of storing binary data as well as only opening one index file containing multiple tags as opposed to multiple index files for each index key. Thanks Once Again Andreas! |