Help on on pre??

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
snapper1969
Posts: 3
Joined: Wed May 13, 2009 4:54 pm

Help on on pre??

Post by snapper1969 » Wed May 13, 2009 4:58 pm

Hi,

I'm totally new to this and am trying to work out how to connect to / create a sqlite db without using on mouse up. I'd like to connect / create the database automatically when the program starts. Can anybody help?.

Thx,

John

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Wed May 13, 2009 8:39 pm

Youy can put something like this in the script of the first card of your stack

Code: Select all

on openStack
  local tPrefsPath, tDbPath
  put specialFolderPath("Preferences") into tPrefsPath
  put tPrefsPath & slash & "MyApp.db" into tDbPath
  global gConnectionId
  put revOpenDabase("sqlite", tDbPath, , , , ) into gConnectionId
  if gConnectionId is not a number then
    answer error "Could not create or open database:" && tDbPath
  end if
end openStack
HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

snapper1969
Posts: 3
Joined: Wed May 13, 2009 4:54 pm

on Pre

Post by snapper1969 » Wed May 13, 2009 9:00 pm

Hi Jan,

Thx for the reply....It's coming up with an error:


stack "Invoice Register": execution error at line 6 (Function: error in function handler) near "revOpenDabase", char 7

Any ideas?.

Thx,

John

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Thu May 14, 2009 5:44 am

Typoes happen - line 6 should read

Code: Select all

put revOpenDatabase("sqlite", tDbPath, , , , ) into gConnectionId
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

snapper1969
Posts: 3
Joined: Wed May 13, 2009 4:54 pm

on Pre?

Post by snapper1969 » Thu May 14, 2009 6:50 pm

Hi Jan,

Thx...I should've posted that, much appreciated.

John

Post Reply