#INCLUDE DEFINES.H

PARAMETER cAppName, cDbName, cDbPath
STORE PARAMETERS() TO lnParams
STORE .F. TO llError, lRelease
ON ERROR llError = .T.
IF TYPE('oSQLSrvr') <> 'O'
        osqlsrvr = createobject('sqlole.sqlserver')
        IF TYPE('oSQLSrvr') <> 'O'
                WAIT WINDOW "Unable to create SQL Server OLE object." TIME 2.0
                RELEASE osqlSrvr
                ON ERROR
                RETURN
        ENDIF
        WAIT WINDOW NOWAIT "Connecting to SQL Server..."
        ret =osqlsrvr.connect(_SQL_SERVER, _SQL_LOGIN, _SQL_PASSWORD)
        IF llError
                WAIT WINDOW MESS() TIME 2.0
                RELEASE osqlSrvr
                ON ERROR
                RETURN
        ENDIF
        lRelease = .T.
ENDIF
oDb = osqlsrvr.databases(cDbName)
IF TYPE('oDb') <> 'O' OR llError
        WAIT WINDOW "Unable to create SQL Server Database object." TIME 2.0
        RELEASE osqlSrvr, oDb
        ON ERROR
        RE