## ams_version=1.0 Section Section_1 { Procedure CreateAccessFileConnectionString { Arguments: (AccessDatabaseFile,ConnectionString); Body: { !Find all ODBC drivers while LoopCount <= SQLNumberOfDrivers( 'odbc' ) do SetElementAdd( Setname : sODBCDrivers , Elempar : epODBCDriver , Newname : SQLDriverName( 'ODBC' , Loopcount) ) ; endwhile ; !First try to find the driver that handles both access 2007 and up !drivers (i.e. .accdb) epODBCDriver := first( iOdbcDrivers | FindString(iOdbcDrivers,"*.accdb" )); !if that does not exist, then try to find the driver that !handles .mdb files if not epODBCDriver then epODBCDriver := first( iOdbcDrivers | FindString(iOdbcDrivers,"*.mdb")); endif ; !If we also could not find this driver, we have a problem... if not epODBCDriver then raise error "Could not find MS Access ODBC driver!" ; endif ; !Now we can create the connection string based on the name of the !driver, the name of the database. We provide the DefaultDir as !an additional argument to ensure that paths relative to the !prj file will work also. If you provide an absolute path as the !first argument, the ODBC layer will discard the DefaultDir information. ConnectionString := SQLCreateConnectionString( DatabaseInterface : 'odbc', DriverName : epODBCDriver, DatabaseName : AccessDatabaseFile, AdditionalConnectionParameters : ";DefaultDir=.\\") ; } Set sODBCDrivers { Index: iOdbcDrivers; } ElementParameter epODBCDriver { Range: sODBCDrivers; } StringParameter AccessDatabaseFile { Property: Input; } StringParameter ConnectionString { Property: Output; } } }