// where .exe started from is default directory //
cFILE := GetModuleFileName( GetInstance() )
mSTART := RAT( "\", cFILE )
cDEFA := SUBSTR(cFILE,1,mSTART-1)
SET DEFA to ( cDEFA )
// setup connection string
xDatabase := "A" // access
*xDatabase := "S" // sql server
If xDatabase = "A"
xPROVIDER := "Microsoft.Jet.OLEDB.4.0"
xSOURCE := cDEFA+"\Travel.mdb"
xPASSWORD := "xxxxxxx"
xCONNECT := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Jet OLEDB:Database Password='+xPASSWORD
Else
xPROVIDER := "SQLOLEDB"
xSOURCE := "RICKLIPKIN-PC\SQLEXPRESS"
xCATALOG := "TRAVEL"
xUSERID := "xxxxxxx"
xPASSWORD := "xxxxxxx"
xConnect := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD
Endif
oRsAactiv := TOleAuto():New( "ADODB.Recordset" )
oRsAactiv:CursorType := 1 // opendkeyset
oRsAactiv:CursorLocation := 3 // local cache
oRsAactiv:LockType := 3 // lockoportunistic
If xDatabase = "A"
cSQL := "SELECT [AactivEid],[Formno],[TravDate],[Code], "
cSql += "[Desc] as Descrip,[Meals],[Mileage],[Perdiem], "
cSql += "[Air],[Other],[Misc],[Regist],[Lodging] "
cSql += "From [Aactiv] where [Formno] = "+ltrim(str(nFormno))
cSql += " and [TravDate] = #"+dtoc(dDate)+"# Order by [TravDate]"
Else
cSQL := "SELECT [AactivEid],[Formno],[TravDate],[Code], "
cSql += "[Desc] as Descrip,[Meals],[Mileage],[Perdiem], "
cSql += "[Air],[Other],[Misc],[Regist],[Lodging] "
cSql += "From [Aactiv] where [Formno] = "+ltrim(str(nFormno))
cSql += " and [TravDate] = '"+dtoc(dDate)+"' Order by [TravDate]"
Endif
TRY
oRsAactiv:Open( cSQL,xCONNECT )
CATCH oErr
MsgInfo( "Error in Opening Aactiv table" )
RETURN(.f.)
END TRY
xConnect := "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Rick.accdb;Persist Security Info=False"
I have decided to just continue to use .mdb since the Microsoft.Jet.OLEDB.4.0 is still native even with Windows 8
1. Can I use mdb with jet oledb even on a PC where MS Access is not installed at all
2. I understand Jet Oledb does not work on 64-bit PC.
( ACE works both on 32 and 64 bits PCs and works both for mdb and accdb )
Rick Lipkin wrote:Rao and Rimantas
As far as Ms Access .. I have found it to be stable using the Ole ( ado ) connectivity ( ms jet ) using "client cached" and "opportunistic locking" recordsets rather than the dot net or VB way. I am re-writing an old VB 6 application re-using the legacy .mdb and during my development, I have treated the access database very badly with ugly abrupt shut downs and even several times with a ctrl-alt-delete and NOT had one single problem with corruption or data loss. Again, I think that is due to how I am using ADO and "client cached" recordsets with "opportunistic locking" and not actually maintaining a full connection to the database.
For relatively small applications to be used on a local lan or as a stand alone environment .. using Ms Access is a good "programming" choice especially using ADO because you can code it once ( and for the most part ) modify ( only ) the connection string and re-compile if you want to migrate the data to Ms Sql Server or Oracle.
Rick Lipkin
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 59 guests