Page 1 of 1

sqlite???

Posted: Fri Jul 13, 2007 8:31 pm
by haribo
Hi,
now, i tried two days with sqlite.
I have tried this code from sampler and works, database is created,

Code: Select all

On preopenstack
  global gConID
  local tConId
  put revOpenDatabase("sqlite","Schule.db",,,,,,) into tConID
  if tConID is "" then 
    answer warning "Problem creating or accessing database!"
  else
    answer information "Schule Connected! Your connection ID is: " & tConID
    put tConID into gConID
  end if
  
  global gConID
  if gConID is "" then
    answer information "No Database is Connected to, please go back 1 step and connect to the Database!"
 
  end if
  
  local tSQL, tResult
  put "CREATE TABLE users(userID integer primary key, name text,email text,emailList boolean)" into tSQL
  revExecuteSQL gConID, tSQL
  put the result into tResult

  if the result is not empty then 
    answer warning the result

  
  put "CREATE TABLE apps(appID integer primary key, appName text,appRegCode text,appUserID integer)" into tSQL
  revExecuteSQL gConID, tSQL
  put the result into tResult

  if the result is not empty then 
    answer warning the result
  end if
  answer information "Number of Tables Added: " & tResult

end if


end preopenstack

when i open the querybuilder, there is no table to select, in Tutorial it looks very easy, but here it doesnt work. What is the problem??
Ralle

Posted: Fri Jul 13, 2007 9:58 pm
by Mark
Hi Ralle,

Your script doesn't run fine, but it doesn't show error messages either because there are a few problems. I cleaned it up to make the error messages appear. I'm not saying the script should run without problems now, but at least you'll see the error messages.

Code: Select all

on preOpenStacks
  -- you should check whether the tables exist
  -- if tables don't exist then create them
  createTables
  -- but I'll leave that as a exercise ;-)
end preOpenStacks



on createTables
  global gConID
  local tSQL, tResult
  put revOpenDatabase("sqlite","Schule.db",,,,,,) into gConID
  if gConID is not an integer then
    answer warning "Problem creating or accessing database! Please go back 1 step and connect to the Database!"
  else
    answer information "Schule Connected! Your connection ID is: " & gConID
  end if
  put "CREATE TABLE users(userID integer primary key, name text,email text,emailList boolean)" into tSQL
  revExecuteSQL gConID, tSQL
  put the result into tResult
  if tResult is not empty then
    answer warning tResult
  end if
  put "CREATE TABLE apps(appID integer primary key, appName text,appRegCode text,appUserID integer)" into tSQL
  revExecuteSQL gConID, tSQL
  put the result into tResult
  if tResult is not empty then
    answer warning tResult
  end if
  answer information "Number of Tables Added: " & tResult
end createTables 
Best,

Mark

Posted: Fri Jul 13, 2007 10:25 pm
by haribo
Hi,
dont work
nothing appears, no db no message, nothing
Ralle
more about my problem.
I create more then 10 db , with msAcess, freeware for windows, sqliteDatabaseBrowser for Mac, there is no way to get it to Rev. Always, nothing appears in querybuilder, no table, open with other apps, the tables are correct, i get crazy

works but not complete

Posted: Sat Jul 14, 2007 3:11 pm
by haribo
when i changed the querybuildersettings it works,
but there is a problem with the primary key, =no primary key,

Code: Select all

local tSQL, tResult
  put "CREATE TABLE schueler(schuelerID integer primary key, name text, vorname text, gebdatum text, strasse text, hausnr text,plz text, ort text, telefon1 text, telefon2 text, telefon3 text, klasse text, geschl text, konf text, staatsang text, nachname2 text, rufname text,email text, emailList boolean)" into tSQL
  revExecuteSQL gConID, tSQL


need help for autoincrement the primary key
ralle