 
 Thanks,
Steve X.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
 
 Hi Steve,SteveX wrote:I am very new to Revolution and I would like some step by step instructions for accessing data in an existing MS Access database. I would like to eventually learn how to add/modify/remove/query this data. Basically I want to be able to build the database structure in MS Access and then use Revolution to build the User Interface. Is this possible? I know I have a ton of new terminology to learn during the conversion from Access to Revolution so be gentle....
Thanks,
Steve X.
 
 
Code: Select all
put revdb_connect("odbc","RevAccessTest",,,) into tConnectionID
-- check if we could connect; if not, show an error
if tConnectionID is not a number then
  answer error tConnectionID
else
  -- we're connected; execute some query
  put "SELECT * FROM customers" into tQuery
  put revdb_querylist(tab,return,tConnectionID,tQuery) into tQueryList
  -- close the connection
  get revdb_disconnect(tConnectionID)
end if



Code: Select all
on mouseUp
  put revdb_connect("odbc","RevAccessTest",,,) into tConnectionID
-- check if we could connect; if not, show an error
if tConnectionID is not a number then
  answer error tConnectionID
else
  -- we're connected; execute the INSERT query
  put "INSERT INTO members VALUES ('" & \
      field "FirstName" & "','" & field "LastName" & "')" \
      into tQuery
  put revdb_execute(tConnectionID,tQuery) into tQueryResult
  -- close the connection
  get revdb_disconnect(tConnectionID)
end if
end mouseUp
Code: Select all
on mouseUp
  put "Update Campers Set LastName='" & SQL_Escaped(fld LastName) & "' where ID=" & fld WID & ";" into uQuery
  put revdb_execute(tConnectionID,uQuery) into dummy
  answer dummy
end mouseUp
function SQL_Escaped pData
  replace "'" with "''" in pData
  return pData
end SQL_Escaped
Code: Select all
on mouseUp
  answer file "Select an Access database"
  if it is empty then exit mouseUp
  put it into tDatabasePath
  -- now get the template script and fill it up
  put the uDSNCreationScript into tVBScript
  replace "[[DatabasePath]]" with tDatabasePath in tVBScript
  ## TIP: look into the 'merge' function!
  -- put the script into a temporary file
  put the tempName & ".vbs" into tScriptPath
  put tVBScript into URL ("file:" & tScriptPath)
  -- and execute it silently
  put the hideConsoleWindows into tSavedHCW
  set the hideConsoleWindows to true
  get shell("cscript.exe //nologo" && tScriptPath)
  set the hideConsoleWindows to tSavedHCW
  -- make sure to clean up the tempprary file
  send "delete file" && quote & tScriptPath & quote to me in 1 second
  -- this gives enough time for the script to run before you delete it
end mouseUp