1

I'm having problems reading a sqlite3 file with TSQLite3Connection in Lazarus with error 'no such table' when I try

myQuery.Active := True;

Here are the steps I made : 1. Drop TSQLite3Connection component to my Form with Name=sqliteconn :

sqlteconn.DatabaseName := 'dbfile'; // the sqlite3 file in the directory of the project 

2. Drop TSQLTransaction component Name=sqlitetransaction :

sqlitetransaction.Active := True;
sqlitetransaction.Database := sqliteconn; 

3. Drop TSQLQuery component with Name=myQuery :

myQuery.Database := sqliteconn; 
myQuery.Transaction := sqlitetransaction;
myQuery.SQL.Text := 'select * from my_table';

4. I want to set Active property of my query to True and get error "no such table: my_table"

I'm 100% sure that 'my_table' is in my "dbfile" so the error must come from something that I've done wrong/missed in my steps to set all connections between my components. Can anyone give me a hint what to change/add to my steps so that my program can start working ?

2 Answers 2

1

I made it work !!! - I don't know why but at design time I fail to set myQuery.Active property to "True", but at run-time this worked :

sqliteconn.DatabaseName := 'dbfile';
sqliteconn.Connected := True;
myQuery.Active := True;

If you can add some comments and explanations how to make it work in design-time also it would be very useful, but until than I think this qualifies as an answer ;)

1

This is because the current directory at design time is not the project one. When the application runs, the file will be found.

If you use the complete path to the file, the connection must work at design time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.