Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Can't get picture from field - Valentina
TCP UDP Xtra
MIAW Event Leak
Soundoftheweb Network
KK
Radio Button Groups
WinDirs XObject
Generic behavior to copy a file
Ripple Button-Alphamania
zLaunch
 

 

 

Behavior Open Recordset

Added on 4/8/2001

 

Compatibilities:
D7 D8 Script

Required Xtras:
ADOXtra

This item has not yet been rated

Author: Eugene Shoustrov (website)

Handler creates a new recordset object, connects it to the MS Access database file dbPath, sets access rights to read or read/write depending on bReadWrite parameter, executes sql query and returns resulting recordset object if successfull or string with error description otherwise.

-- Coded by Eugene Shoustrov
-- author@adoxtra.com

on OpenRecordset dbPath, sql, bReadWrite
  if voidP(bReadWrite) then bReadWrite=false
  
  if voidP(sql) then return "sql param is missed"
  if voidP(dbPath) then return "dbPath param is missed"
  
  -- Creating recordset object
  rst=CreateObject(xtra "ADOxtra",#recordset)
  if not objectP(rst) then return rst
  
  -- Building connection string
  -- Microsoft Jet provider for MS Access databases
  cnnStr="Provider=Microsoft.Jet.OLEDB.4.0;"
  cnnStr=cnnStr&"Data Source="&dbPath&";"
  if bReadWrite then
    cnnStr=cnnStr&"Mode=Read|Write;"
  else
    cnnStr=cnnStr&"Mode=Read;"
  end if
  
  -- Connecting to the db
  rst.ActiveConnection=cnnStr
  if rst.failed then return rst.lastError
  
  -- Adjusting cursor and lock type
  if bReadWrite then
    rst.lockType=rst.adLockPessimistic
    rst.CursorType=rst.adOpenKeyset
  else
    rst.lockType=rst.adLockReadOnly
    rst.CursorType=rst.adOpenStatic
  end if
  
  -- Opening recordset
  rst.Open(sql)
  if rst.failed then return rst.lastError
  
  return rst
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail