Connect:
Code: Select all
on mouseUp
local tDatabasePath, tDatabaseID
## The database must be in a writeable location
put specialFolderPath("documents") & "/localinfo.sqlite" into tDatabasePath
## Open a connection to the database
## If the database does not already exist it will be created
put revOpenDatabase("sqlite", tDatabasePath, , , , ) into tDatabaseID
## Store the database id so other handlers can access it
setDatabaseID tDatabaseID
end mouseUp
local sDatabaseID
command setDatabaseID pDatabaseID
put pDatabaseID into sDatabaseID
end setDatabaseID
function getDatabaseID
return sDatabaseID
end getDatabaseID
Code: Select all
on databaseCreateTable
## Add a contact_details table to the database
put getDatabaseID() into tDatabaseID
put "CREATE TABLE local_info (State char(50), City char(50), Login_count (50), User_Name (50), )" into tSQL
revExecuteSQL tDatabaseID, tSQL
end databaseCreateTable
Code: Select all
global gState, gCity, gLogin_Count, gUser_Name
on databaseInsertlocal_info
put the text of field "State" into gState
put the text of field "City" into gCity
put the text of field "Login_Count" into gLogin_Count
put the text of field "User_Name" into gUser_Name
put getDatabaseID() into tDatabaseID
put "INSERT into local_info VALUES (" && "'" & gState & "'" && "," && "'" & gCity & "'" && "," && "'" & gLogin_Count & "'" && "," && "'" & gUser_Name & "'" && ")" into tSQL
revExecuteSQL tDatabaseID, tSQL
end databaseInsertlocal_info
Code: Select all
on mouseUp
put databaseGetlocal_info() into field "local_info"
end mouseUp
function databaseGetlocal_info
## Query the database for contact details to be displayed in the field
put getDatabaseID() into tDatabaseID
put "SELECT * from local_info" into tSQL
put revDataFromQuery(tab,return,tDatabaseID,tSQL) into tRecords
return tRecords
end databaseGetlocal_info