Hello,
I am testing liteDac library.
I can connect to the database when I drop the component on the VCL form.
I was trying to do the same thing in the code; however, I get error when I try to establish connection. Any help would be appreciated.
sqliteQuery : TLiteQuery;
sqliteConnection : TLiteConnection;
sqlQry : TSqlStatements;
databasePath : string;
begin
databasePath := 'C:\Users\chris\Documents\Dev\Delphi\sqlite_test\dv.db3';
sqlQry := TSqlStatements.create(FUserInput);
sqliteConnection := TLiteConnection(nil);
sqliteQuery := TLiteQuery.Create(nil);
try
sqliteConnection.LoginPrompt := false;
sqliteConnection.Database := databasePath;
sqliteConnection.Options.Direct := true;
if not(sqliteConnection.Connected) then
sqliteConnection.Open;
sqliteQuery.ReadOnly := true;
sqliteQuery.SQL.Clear;
sqliteQuery.SQL.Add(sqlQry.stateSql);
sqliteQuery.Prepared := true;
sqliteQuery.Execute;
I tried to use a connection string:
sqliteConnection.ConnectString:= 'Login Prompt=False;Database=C:\Users\tpdzaja\Documents\Dev\Delphi\sqlite_fireDac\dv.db3;Direct=True';
Did not work.
I would appreciate any help.
Thanks,
Chris
Building connection string in the code
Re: Building connection string in the code
Unfortunately, we can not reproduce the problem. We have modified the code you provided to use with the connection string, and it works without any problems.
Can you explain in more details what do you mean by "did not work". What is the exact error message you are getting?
Code: Select all
...
try
sqliteConnection.ConnectString:= 'Login Prompt=False;Database=C:\Users\tpdzaja\Documents\Dev\Delphi\sqlite_fireDac\dv.db3;Direct=True';
if not(sqliteConnection.Connected), then
sqliteConnection.Open;
...
Re: Building connection string in the code
Hello,
I rewrote the routine from the beginning and it worked.
I am not sure why I could not get to work in the first place.
I am sorry for extra trouble.
On a better note, I like the LiteDac library. I will buy; plus your help files are much better than FireDac.
Chris
I rewrote the routine from the beginning and it worked.
I am not sure why I could not get to work in the first place.
I am sorry for extra trouble.
On a better note, I like the LiteDac library. I will buy; plus your help files are much better than FireDac.
Chris
Re: Building connection string in the code
Thank you for your interest in our products.
Feel free to contact us if you have any further questions about LiteDAC.
Feel free to contact us if you have any further questions about LiteDAC.