Hi All,
I have been searching the forums for a simple guide to using wxSqlite3 with Code::Blocks and wxWidgets 2.8.12 on Windows7. I have previously been using RealBasic to create a database front end but I need more control over the program and so am trying to move to C++ through wxWidgets under Code::Blocks.
So far the GUI is fine and I am learning the basics reasonably quickly. However, I can't work out how to get the program to interact with my Sqlite3 database.
Some forum entries complain about the problems compiling the wxSqlite3 DLL (which is something I always struggle with). However, I have seen suggestions that this is not necessary and all I have to do is to include the wxSqlite3 source files in my Code:Blocks project. This seems simple enough but I am not sure how to achieve this.
A simple step-by-step guide would be very welcome ... either to compile the DLL or to include the source files in my project.
Talking of DLL's, is it possible to rename the DLL's used by my program? For example; MyProg1.dll and MyProg2.dll.
Thanks in advance for your help,
Alan ...
Edit: Well! I managed to include the wxSqlite3 files into a test project - simple really - but I haven't yet tried to connect with a database. I'm sure it's quite straightforward (Why do we always try to make these things so difficult?) but ... I'm having great difficulty compiling the Dataview sample and I think the makefile is wrong. Is there a tutorial to show me how to correct this or, better still, an updated makefile that I can copy or download?
Again, any help will be greatly appreciated.
Alan ...
wxSqlite3 help please
Re: wxSqlite3 help please
This is really straight forward: you need a wxSQLite3Database object for each separate database connection. This object is then used to insert, modify, delete or select data to/from the database.mct1949 wrote:So far the GUI is fine and I am learning the basics reasonably quickly. However, I can't work out how to get the program to interact with my Sqlite3 database.
I don't use Code::Blocks myself, so I can't give detailed instructions. However, wxSQLite3 consists of only a single C++ source file and a few header files. It should be easy to set up a C::B project to compile wxSQLite3. The somewhat difficult part might be to set up the necessary include and link paths to the SQLite3 library and to set compiler defines to get the compile time options right. (You may use one of the precomiled SQLite3 DLLs coming with wxSQLite3; link libraries for GCC are included. Or you may compile SQLite3 yourself, i.e. if you want to use it as a static library. You'll find detailed instructions how to do that on this forum.)mct1949 wrote:Some forum entries complain about the problems compiling the wxSqlite3 DLL (which is something I always struggle with). However, I have seen suggestions that this is not necessary and all I have to do is to include the wxSqlite3 source files in my Code:Blocks project. This seems simple enough but I am not sure how to achieve this.
Then there is a premake4 build file coming with wxSQLite3. Premake4 is able to generate C::B project files. It might be required to adjust the premake4 build file, though, because I haven't tested it with C::B.
In my own projects I usually include wxSQLite3 directly by adding the source files to the project.
Usually this will not work, if you use so called link libraries to build your application, since a link library refers to the DLL by its file name. However, you could load a DLL dynamically by using for example the class wxDynamicLibrary. In that case you are free to rename your DLL.mct1949 wrote:Talking of DLL's, is it possible to rename the DLL's used by my program? For example; MyProg1.dll and MyProg2.dll.
Take a look at the minimal sample coming with wxSQLite3. Although it's a command line application it shows you almost all operations you need to connect to a SQLite3 database, enter data into it and retrieve data from it.mct1949 wrote:Edit: Well! I managed to include the wxSqlite3 files into a test project - simple really - but I haven't yet tried to connect with a database. I'm sure it's quite straightforward (Why do we always try to make these things so difficult?)
In my own application I usually have a common wxSQLite3Database instance through which all database activities are executed. Beware, if you use multi-threading in your application: a separate wxSQLite3Database instance should be used for each concurrent thread.
Within a wxWidgets GUI application you usually have a method to initialize controls. In this method you could read values from a database connection to fill your controls with values. Of course this depends on the type of controls. For a wxGrid control you would derive a class from wxGridTableBase.
Of which sample are you talking? The dataview sample in the wxWidgets distribution? Maybe you'll find some hints on the Code::Blocks forums about how to compile wxWidgets samples.mct1949 wrote:but ... I'm having great difficulty compiling the Dataview sample and I think the makefile is wrong. Is there a tutorial to show me how to correct this or, better still, an updated makefile that I can copy or download?
Regards,
Ulrich