slqite3 issue

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
vdubeau
Posts: 1
Joined: Saturday 27th January 2024 11:26pm

slqite3 issue

Post by vdubeau »

I tried following examples. my code is below:

Dim $con As New Connection
Try $con.Close()
$con.Type = "sqlite3"
$con.host = "./"
$con.name = "Invoices.db"
$con.Open
I get the message "Unable to locate database 'invoices.db' in ./"

I have the database file in the directory where the program resides.
What am i doing wrong? Any help is appreciated.

Thanks
User avatar
BruceSteers
Posts: 1579
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: slqite3 issue

Post by BruceSteers »

did you try an absolute path?

$con.host = Application.Path

I'd use the ./ path only for reading files, for writing (or other uses, i guess db) then i'd use Application.Path
If at first you don't succeed , try doing something differently.
BruceS
Online
User avatar
thatbruce
Posts: 168
Joined: Saturday 4th September 2021 11:29pm

Re: slqite3 issue

Post by thatbruce »

Two notes:
1) You CANNOT write to a database inside the executable(nor any other file inside the executable.) The database must exist outside the executable.
2) As Bruce says you must use a FULL path to the sqlite file. Read up up on how Gambas uses relative paths.
b
Have you ever noticed that software is never advertised using the adjective "spreadable".
Post Reply