code for placing data into my table_
Code: Select all
on mouseUp
--Connect to DB
connectMe
--Choose File
answer file "Select a file:"
if the result is not "Cancel" then
put it into tChosenFile
end if
put URL ("binfile:" & tChosenFile) into tDocuments
-- check the global connection ID to make sure we have a database connection
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
--Table Names
put "jcasMessages" into tTableName
put "date,subject, body,attachment" into tFields
--Just some data for testing
put "" into tDate
put "TestDoc" into tSubject
put "test" into tBody
put tDocuments into tAttachment
-- construct the SQL - the :1, :2 & :3 placeholders in the SQL will be filled by variables in the revExecuteSQL line
put "INSERT INTO " & tTableName & " (" & tFields & ") VALUES (:1, :2, :3, :4)" into tSQL
-- send the SQL to the database, filling in the placeholders with data from variables
revExecuteSQL gConnectionID, tSQL,"tDate", "tSubject", "tBody", "tAttachment"
-- check the result and display the data or an error message
if the result is a number then
answer info "Message Sent!"
else
answer error "There was a problem adding the record to the database:" & cr & the result
end if
end mouseUp
Code: Select all
on mouseUp
--connect to DB
connectMe
-- check the global connection ID to make sure we have a database connection
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
-- construct the SQL (this selects all the data from the specified table)
put "jcasMessages" into tTableName -- set this to the name of a table in your database
put "SELECT attachment FROM jcasMessages WHERE subject='TestDoc'" into btSQL
-- query the database
put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
-- check the result and display the data or an error message
if item 1 of btData = "revdberr" then
answer error "There was a problem querying the database:" & cr & tData
else
put tData into field "testing"
end if
end mouseUp