2

I am getting sqlite3.dll not found error at Delphi app. I already have sqlite3.dll file on my PC located at E://sqlite-dll-win32-x86-3071700

My source is as follows

procedure TForm2.Button1Click(Sender: TObject);
var
    Results: TDataSet;
begin
    SQLConnection1.Params.Add('Database=E://empn.s3db');
    SQLConnection1.LibraryName := 'E://sqlite-dll-win32-x86-3071700/sqlite3.dll';
    try
        SQLConnection1.Connected := true;
        SQLMonitor1.Active := True;

        SQLConnection1.Execute('Selct * from usergroup', nil, Results)

    finally

    end;
end;

As mentioned in above code already pointed out path to the library by

SQLConnection1.LibraryName := 'E://sqlite-dll-win32-x86-3071700/sqlite3.dll';

But still I do get error like sqlite3.dll not found. how to troubleshoot this error?

4
  • 1
    Don't you mean 'E:/sqlite-dll-win32-x86-3071700/sqlite3.dll' or 'E:\sqlite-dll-win32-x86-3071700\sqlite3.dll' Commented Aug 26, 2013 at 11:17
  • Tried out it by all ways changing slashes like E:\sqlite-dll-win32-x86-3071700\sqlite3.dll & 'E:/sqlite-dll-win32-x86-3071700/sqlite3.dll, getting same error. Is it recommended to copy sqlite3.dll into windows/system32 folder ? As this path is already defined at environment variables. Commented Aug 26, 2013 at 11:56
  • Try puts DLL to system folder, and use it without absolute paths. Commented Aug 26, 2013 at 12:00
  • 4
    Don't put the DLL in the system folder. The system folder is owned by the system. The clue is in the name! The right place for it is alongside the executable. Commented Aug 26, 2013 at 12:04

5 Answers 5

5

A small note

Beginning with Delphi XE3, LibraryName is obsolete.

In older Delphi versions, LibraryName indicated the "dbExpress library associated with the driver" (e.g. dbxfb.dll for Firebird), while VendorLib indicated the "library supplied by the database vendor to support client-side use of the database" (e.g. fbclient.dll/fbembed.dll for Firebird, equivalent to Sqlite's sqlite3.dll).


Embarcadero's Sqlite dbExpress driver

In you are on Windows, this driver uses delayed loading of sqlite3.dll. Something like:

function sqlite3_open_v2; external 'sqlite3.dll' delayed;

so the dll is loaded with LoadLibrary and the standard search strategy to find modules applies (first the process directory, then the usual path list).

However this stategy can be altered by using SetDllDirectory.

So you have to put sqlite3.dll accessible thru your path or try the following hack:

(beware that this will interfere with other code that have used SetDllDirectory; see David Heffernan's comment)

SetDllDirectory('E:\sqlite-dll-win32-x86-3071700');
try
  SQLConnection1.Open;
finally
  SetDllDirectory(''); // restore default search order
end;

Warning: Also make sure that you are not mixing 32 and 64 bits modules (i.e. 32 bit exe and 64 bit dll or vice versa).

Sign up to request clarification or add additional context in comments.

4 Comments

Your use of SetDllDirectory will interfere with any other code in the process that tries to use it. Better put the dll in exe directory. Or call LoadLibrary passing the full path to dll. That way the later call to LoadLibrary name by delay load mechanism will find the module already loaded.
I think none of this will work unless OP has dbExpress driver for SQLite or more recent version of Delphi. It's not enough to set the proper SQLite library path when dbExpress doesn't know how to work with it. @Ninad, could you add a tag with your version of Delphi in your question ?
Already put dll in exe directory but error persists...@TLama version tag added.
@JRL Already seen your message it is not mixed up above check the folder name sqlite-dlll-win32. It is DLL for win32, mine is 32 bit OS.
2

The same error occurs in Delphi XE7, download from https://www.sqlite.org/download.html, the binaries for windows and copy de sqlite3.def also in the system file you are using (system32 or SysWOW64). It seems it is missing in the installation of Delphi XE7.

Comments

1

According to this Embarcadero blog article, the steps you need to take are:

  1. Download the SQLite client from http://www.sqlite.org/download.html.
  2. Make sure that sqlite3.dll can be found by your application.
  3. Add a TSQLConnection instance and set the Driver property to Sqlite.

It looks to me as though you have not performed step 3.

Regarding step 2, the preferred way to achieve that is to put the DLL in the same directory as your executable.

7 Comments

TSQLConnection driver property is already set to the sqlite, I am writing code according to the instructions from embarcadero blog itself ...docwiki.embarcadero.com/RADStudio/XE3/en/… have posted question here by cross checking everything from my side. Whatever I have not tried yet is DBExpress Driver..
The link you gave points to nothing. Can you point me to the Embarcadero post that instructs you to use the code that appears in the question?
Your code in the question indicates that you are not following the tutorial. Try and do exactly what it says.
Even if I put the code exactly same as the tutorial I do get same error after clicking execute button. I modified code to simple form to troubleshoot error by declaring path at LibraryName property & table already exists at s3db file.
|
1

@TLama, @David Heffernan, JRL and many others, it worked out finally with Dotconnect for SQLite. I have not tried yet DBExpress Driver For SQLite as suggested by TLama. I think DBExpress Driver would also have resolved issue as both dotconnect and DBExpress driver have similar utility.

Comments

1

I had the same issue with Delphi XE7. Turns out I had downloaded the 64-bit DLL but the application is 32-bit. I copied the 32-bit DLL to the application folder and I was then able to connect. Someone (JRL) stated this above...

Warning: Also make sure that you are not mixing 32 and 64 bits modules (i.e. 32 bit exe and 64 bit dll or vice versa).

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.