ADOxtra for Macromedia DirectorOpenRecordset sample script
See ADOxtra castlib in Downloads section for this handler and other useful Lingo for ADOxtra.
-- Handler creates a new recordset object
-- connects it to the MS Access database dbPath
-- sets access rights to read or read/write depending on bReadWrite parameter
-- executes SQL query and returns resulting recordset object if successful or
-- string with error description otherwise
on OpenRecordset dbPath, sql, bReadWrite
if voidP(bReadWrite) then bReadWrite=false
if voidP(sql) then return "OpenRecordset: Required parameter is missing: "&sql
if voidP(dbPath) then return "OpenRecordset: Required parameter is missing: "&dbPath
-- Creating recordset object
rst=createObject(xtra "ADOxtra",#recordset)
if not objectP(rst) then return rst
-- Building connection string
cnnStr="Provider=Microsoft.Jet.OLEDB.4.0;" -- Microsoft Jet provider for MS Access databases
cnnStr=cnnStr&"Data Source="&dbPath&";"
if bReadWrite then
cnnStr=cnnStr&"Mode=Read|Write;"
else
cnnStr=cnnStr&"Mode=Read;"
end if
rst.ActiveConnection=cnnStr
if rst.failed then return rst.lastError
if bReadWrite then
rst.lockType=rst.adLockPessimistic
rst.CursorType=rst.adOpenKeyset
else
rst.lockType=rst.adLockReadOnly
rst.CursorType=rst.adOpenStatic
end if
rst.Open(sql)
if rst.failed then return rst.lastError
return rst
end
|