how works the TSQLDBLibraryLoader component? lazarus / 16-Databases ---------------------------------------------------------------------- franciscoluiz · 2012-12-17 14:42 hello to all ... I'm using lazarus 1.1, 14/12/2012, fpc 2.7.1 32bit I've been testing a connection with sqlite... But when i try connect to database, in design mode, appears "Can not load SQLite client library "SQLite3.dll". Check your installation.", but works in execution time... the sqlite3.dll was in the same folder of exe... and I have one button with: Code: [Select]  SQLConnector1.Connected:=true;   SQLQuery1.Close;   SQLQuery1.SQL.Clear;   SQLQuery1.SQL.Text:='select * from teste';   SQLQuery1.Open;  this works in execution time... well, i try to use SQLDBLibraryLoader, but how i use that? i change the sqlite3.dll location to another folder... and i try to do: Code: [Select]SQLDBLibraryLoader1.LibraryName := 'c:\new_path_to_sqllite_dll\sqlite3.dll';   SQLDBLibraryLoader1.ConnectionType:='SQLite3';   SQLDBLibraryLoader1.Enabled := true;   SQLDBLibraryLoader1.LoadLibrary; but don't works... how i can do that? here, one example with source: http://www.sendspace.com/file/jwhdce where/what am I doing wrong? thank you, Francisco ---------------------------------------------------------------------- BigChimp · 2012-12-17 14:51 If your application fails with the sqlite library in your application folder you may be using the wrong sqlite dll (64 bit if compiling 32 bit application and vice versa), you might be missing required dlls etc. More likely is that the folder where the exe is created is different from the source files (e.g. in a subdirectory bin or lib). In design time, Lazarus looks in the directory with the sources, not a separate output directory. Try copying the dll to the sources directory then. Using SQLDBLibraryLoader should not be necessary... ---------------------------------------------------------------------- franciscoluiz · 2012-12-17 15:06 thanks for the reply, BigChimp. I'm using the correct version of sqlite ... if I put the dll in the exe folder, works perfectly. is the correct version. My question is about the use of TSQLDBLibraryLoader ... really, it is not necessary, but in my application, the user could choose the server database, and I want to put the dll libraries organized in a folder for this purpose ... I can not even implement it ... but I would like to know and learn how to properly use the TSQLDBLibraryLoader ... Thank you again, Francisco ---------------------------------------------------------------------- BigChimp · 2012-12-17 15:18 Then I don't understand this: Quote from: franciscoluiz on December 17, 2012, 03:42:41 pmBut when i try connect to database, in design mode, appears "Can not load SQLite client library "SQLite3.dll". Check your installation.", but works in execution time... but never mind. Regarding the loader: search the FPC mailing list for the announcement (last couple of months) by Michael Van Canneyt, including code sample. ---------------------------------------------------------------------- franciscoluiz · 2012-12-17 18:32 when i said this: Quote from: franciscoluiz on December 17, 2012, 03:42:41 pmBut when i try connect to database, in design mode, appears "Can not load SQLite client library "SQLite3.dll". Check your installation.", but works in execution time... i'm talking about connect to database, without the TSQLDBLibraryLoader... without the SQLDBLibraryLoader... when i try connect to database, in design mode, appears "Can not load SQLite client library "SQLite3.dll", but (even without TSQLDBLibraryLoader) works in execution time... I'll look for messages of Michael Van Canneyt... Thank you again! ---------------------------------------------------------------------- BigChimp · 2012-12-17 19:48 Quote from: franciscoluiz on December 17, 2012, 07:32:25 pmi'm talking about connect to database, without the TSQLDBLibraryLoader... without the SQLDBLibraryLoader... when i try connect to database, in design mode, appears "Can not load SQLite client library "SQLite3.dll", but (even without TSQLDBLibraryLoader) works in execution time... As I said: Quote from: BigChimpMore likely is that the folder where the exe is created is different from the source files (e.g. in a subdirectory bin or lib). In design time, Lazarus looks in the directory with the sources, not a separate output directory. Try copying the dll to the sources directory then. Good luck with the search ---------------------------------------------------------------------- franciscoluiz · 2012-12-17 20:48 thank you mr. BigChimp! a friend of a forum in my language solved the problem. SQLDBLibraryLoader the works as it should ... only it does not work exactly for SQLite ... in the source of "sqlite3conn", in TSQLite3ConnectionDef were missing some functions such as TSQLite3ConnectionDef class function. DefaultLibraryName: String; override; TSQLite3ConnectionDef class function. LoadFunction: TLibraryLoadFunction; TSQLite3ConnectionDef class function. UnLoadFunction: TLibraryLoadFunction; such functions are found in other libraries of others databases... I tested the SQLDBLibraryLoader with mysql and it worked perfectly, it is specific with sqlite. thank you again mr. Banana! ---------------------------------------------------------------------- BigChimp · 2012-12-18 07:23 Glad it works FYI: Current FPC trunk may I think very well have fixed these sqlite issues... Anyway, started some documentation: http://wiki.lazarus.freepascal.org/SQLDBLibraryLoader contributions to that wiki page & corrections more than welcome Mr Banana ---------------------------------------------------------------------- franciscoluiz · 2014-03-28 19:48 The error keeps occurring: "Can not load SQLite client library "sqlite3.dll". Check your installation." My code: Code: [Select]  SQLDBLibraryLoader1.LibraryName := ExtractFilePath(Application.ExeName) + '\sqlite3wx.dll';   SQLDBLibraryLoader1.ConnectionType := 'SQLite3';   SQLDBLibraryLoader1.Enabled := True;   SQLDBLibraryLoader1.LoadLibrary;   SQLConnector1.DatabaseName := ExtractFilePath(Application.ExeName) + '\sqlite.db';   SQLConnector1.ConnectorType := 'SQLite3';   SQLConnector1.Connected := True; sqlite3wx.dll is the library that I use wxSQLite3 from wxCode ( http://wxcode.sourceforge.net/components/wxsqlite3/ ) I'm using Lazarus 1.3, (2014/02/25), i386-win32, fpc 2.6.2 ---------------------------------------------------------------------- JanRoza · 2014-03-28 23:07 Why do you use sqlite3wx.dll from a strange website? Try using sqlite3.dll which you can download from SQLites own website http://www.sqlite.org/2014/sqlite-dll-win32-x86-3080402.zip ---------------------------------------------------------------------- franciscoluiz · 2014-03-28 23:56 Ok JanRoza, but wxcode is not a stranger to me. and even if it were, I take responsibility. And I use the wxSQLite3 encryption system, which does not exist natively in the official SQLite. I work this way been a while, using the zeos. and I will use only the official sqlite when it supports native encryption and free of charge, such like wxcode. Code: [Select]wxSQLite3 includes an optional extension for SQLite supporting key based database file encryption using 128 bit AES encryption. Starting with version 1.9.6 of wxSQLite3 the encryption extension is compatible with the SQLite amalgamation source. Experimental support for 256 bit AES encryption has been added in version 1.9.8. [code] I hope to learn and understand how to use this native functionality (TSQLDBLibraryLoader) of SQLDB... I wish I could learn to using and enjoying this functionality even if in a future I no longer use this dll. ---------------------------------------------------------------------- JD · 2014-03-29 10:23 Quote from: franciscoluiz on March 28, 2014, 08:48:27 pmThe error keeps occurring: "Can not load SQLite client library "sqlite3.dll". Check your installation." sqlite3wx.dll is the library that I use wxSQLite3 from wxCode ( http://wxcode.sourceforge.net/components/wxsqlite3/ ) Have you tried renaming 'sqlite3wx.dll' to 'sqlite3.dll'? ---------------------------------------------------------------------- franciscoluiz · 2014-03-29 11:40 well... yes JD, and works perfectly... I would just like to know why I can change the LibraryName property if I can not choose the file name... This property could be nominated for LibraryPath, since I can not choose the name of the library... ---------------------------------------------------------------------- BigChimp · 2014-03-29 11:47 http://wiki.lazarus.freepascal.org/SQLDBLibraryLoader "SQLDBLibraryLoader needs to be called before loading/enabling TSQLConnection components." ... so probably you'd have to do this before SQLConnector1.Create... or if you use graphical components, hopefully this is done for you... Also, I'm assuming this happens at runtime not designtime - presumably then you'd fill out the properties of the GUI libraryload component... ---------------------------------------------------------------------- BigChimp · 2014-03-29 11:56 Also, you may be dealing with the same bug as mentioned above.... Please file a bug report if my previous post doesn't fix things for you... thanks. ---------------------------------------------------------------------- BigChimp · 2014-03-29 14:11 Note: updated example code at http://wiki.lazarus.freepascal.org/SQLDBLibraryLoader#Sample_code ... because first setting the library name then connection type won't work... (connection type resets the library name to default name for that database) Also looking into sqlite3 and tsqldblibraryloader... seems it is also not implemented in trunk... looking if I can fix it... ---------------------------------------------------------------------- franciscoluiz · 2014-03-29 20:09 thank you all... thank bigchimp... well mr.banana, I put on the config lines of SQLDBLibraryLoader on FormCreate. And to "ensure" the connection component was created later, at run time... I also changed the order of the lines as suggested in the wiki. And the error persists, only works if the file is called precisely sqlite3.dll and not otherwise. ---------------------------------------------------------------------- franciscoluiz · 2014-03-29 20:36 I created a new issue in bugtracker: http://bugs.freepascal.org/view.php?id=25947 ---------------------------------------------------------------------- BigChimp · 2014-03-30 08:57 Thanks for posting the bug report. I added support for sqlite3 SQLDBLibraryLoader; it was committed to trunk (i.e. FPC 2.7.1) yesterday. Works for me on trunk with test program I uploaded to bug report: http://bugs.freepascal.org/file_download.php?file_id=19778&type=bug ---------------------------------------------------------------------- freeman35 · 2014-09-12 08:44 @BigChimp this is your example code from your link Code: [Select]  LibLoader:=TSQLDBLibraryLoader.Create(nil);   try     LibLoader.ConnectionType:='SQLite3';     LibLoader.LibraryName:=paramstr(1);     LibLoader.Enabled := true;     LibLoader.LoadLibrary;   finally     LibLoader.Free;   end; Conn:=TSQlite3Connection.create(nil);   try     Tran:=TSQLTransaction.create(nil);     Q:=TSQLQuery.Create(nil);     Conn.DatabaseName:='test.sqlite'; ...this is my code: Code: [Select]procedure TDM.DataModuleCreate(Sender: TObject); begin   db_name := 'Stock.dbe';   db_name := ConcatPaths([ExtractFileDir(ParamStr(0)), db_name] );   SQLite3Conn.DatabaseName := db_name;   SQLiteLibraryName:=ConcatPaths([ExtractFileDir(ParamStr(0)), 'sqlite3win32.dll'] );   {$IFDEF WINCE}    SQLiteLibraryName:='sqlite3arm.dll';   {$ENDIF}   {$IFDEF LINUX}     SQLiteLibraryName:='libsqlite3.so.0.8.6';   {$ENDIF} SQLite3Conn.Open;// just add here for show how to use open. In my code not in oncreate end; I used fpc svn & lazarus svn. I wrote in win32 then crosscompile to wince. (I wish to use real my system(kubuntu x64) for write code then crosscompile but many bugs lazarus and fpc ) My question is in your code TSQLDBLibraryLoader created and loadlibrary then class be free, why ? TSQLDBLibraryLoader class is just for check for library is right ? or any set to sql db connection library file ? I mean,I wanna use TIBConnection, its libraryname creation rules Code: [Select]/freepascal/2.7.1/packages/ibase/src/ibase60.inc  const     gdslib = 'libgds.'+sharedsuffix; // Needs completion ?     libfc  = 'libfbclient.'+sharedsuffix;     libem  = 'libfbembed.'+sharedsuffix;     v2  = {$ifndef darwin}'.2'{$else}''{$endif};     v21 = {$ifndef darwin}'.2.1'{$else}''{$endif};     v25 = {$ifndef darwin}'.2.5'{$else}''{$endif};     v251 = {$ifndef darwin}'.2.5.1'{$else}''{$endif}; But I have Installed firebird 2.5.3 version. If I put TSQLDBLibraryLoader on form and set library name, then can I use TIBConnection with my library (2.5.3) and in osx ? TSQLDBLibraryLoader is for this ? Another way, for axmple, I have firebird 1.5 db and data, I wanna copy data to firebird 2.5.3 db, I need to load both library same form and same time, so I can dump data, how to do this? Thank you ---------------------------------------------------------------------- BigChimp · 2014-09-12 08:54 Please read the documentation on TSQLLibraryLoader, thanks. AFAIR it loads the library it is not meant as a check for the correct name. That's why it needs to be called before doing anything with your connections. I have Firebird 2.5.x on my Linux machine; it runs without any problems without tsqllibraryloader because the OS/package manager created symlinks from libfbclient.2.5.so (or whatever it is called) to the real library. See the firebird page on the wiki for instructions on what to install (hint: the firebird and the firebird-dev packages on the machine where you're compiling). FIrebird 2.x can read older ODS/Firebird files so I don't see why you should need to load 2 libraries. Otherwise perhaps do use tsqllibraryloader. Don't know if that will work; you will have to find out. Finally, in future please start a new thread for a new problem. Your problem is different from the OP's problem and this confuses the thread and will also lead to less people looking at the thread. Thanks. ---------------------------------------------------------------------- freeman35 · 2014-09-12 12:14 Quote from: BigChimp on September 12, 2014, 10:54:40 amPlease read the documentation on TSQLLibraryLoader, thanks. Yes I did read documentation, wiki web site's owner is different then lazarus and fp, so that site can close, and wiki pages be old. like first link of "TSQLDBLibraryLoader" http://wiki.lazarus.freepascal.org/SQLDBLibraryLoader so my idea is best way use forum. web search engine like google hold subject and message body, and all forum member reupdate message. Quote from: BigChimp on September 12, 2014, 10:54:40 amFinally, in future please start a new thread for a new problem. Subject is "how works the TSQLDBLibraryLoader component?" and not different my questions, why need start new thread? If I start new thread and some will say why open new one, there is still have same subject Quote from: http://wiki.lazarus.freepascal.org/TSQLDBLibraryLoader Overview: TSQLDBLibraryLoader is a Lazarus and FPC component that specifies the names and locations of SQLDB database libraries (DLLs/.sos/.dylibs) should be loaded from where. Use and alternatives For SQLDB database connectors, at least recent FPC versions try to load some default library names, but may fail. Using SQLDBLibraryLoader, you can specify the exact filename to load. SQLDBLibraryLoader needs to be called before loading/enabling TSQLConnection components. Note that often you can a similar thing by setting the library name for the TSQLConnection descendant you are using. This does depend on that TSQLConnection descendant supporting that functionality. TSQLConnection has no property about TSQLDBLibraryLoader, TIBConnection too. For example: We have 2 db, "old.db" is firebird 1.5.6 and second is "new.db" and its firebird 2.5.3. and system is linux x64 and firebird 2.5.3 installed. and job is, connect to "old.db" and get data, then connect to "new.db" and write data from "old.db" new.db connection is okey, because fb 2.5.3 installed, but what have do for old.db? need embeded connection for fb 1.5.6. I want to know how to? second example: pc has installed firebird 1.5.6 and data and application work on this. I wanna make new application, and make demo on this pc, but new application need firebird 2.5.3 application have work embeded fb 2.5.3 and not talk yet about firebird 3.0 beta test second demo application need firebird 3.0 I hope I can translate my idea. Please do not forget, we are not same country, and same culture, english is not mine language, maybe not yours too. and no gestures on writing, sometime can make wrong understanding this. Thank you ---------------------------------------------------------------------- BigChimp · 2014-09-12 12:21 Sorry, I've said all I wanted to say - in this thread and the ibxconnection thread. I can't really help you further - it seems you do not understand what I mean and yes, that can be a culture/language thing.