User forums > Using Code::Blocks
[SOLVED] SQLite3 in a C::B GUI
(1/1)
Landslyde:
There are a LOT of tutorials on youtube showing how to use SQLite3 with a C::B console program. ONE shows a GUI through the use of wxSQLite3, but this guy doesn't speak or explain anything. And some of what he does is obscure as hell! Will someone puhleeeez point me to a link that goes step by step on how I can implement SQLite3 in a C::B GUI program? I'm doing this right now using Qt (they have the SQL drivers built in and accessing them is a breeze), but I detest using their hybrid C++! I want pure C++ through C::B to build my SQLite3 programs.
I've tried adding the sqlite3.c and sqlite3.h to a C::PB GUI and immediately get a mile of errors in the buffer.h file:
--- Code: ---||=== Build: Debug in Assistant (compiler: GNU GCC Compiler) ===|
||warning: command line option ‘-std=c++1z’ is valid for C++/ObjC++ but not for C|
||warning: ./wx_pch.h.gch/Debug_wx_pch_h_gch: not for GNU C11|
/usr/include/wx-3.0/wx/buffer.h|19|error: unknown type name ‘class’|
/usr/include/wx-3.0/wx/buffer.h|27|error: unknown type name ‘namespace’; did you mean ‘isspace’?|
/usr/include/wx-3.0/wx/buffer.h|28|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
/usr/include/wx-3.0/wx/buffer.h|65|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token|
/usr/include/wx-3.0/wx/buffer.h|241|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token|
/usr/include/wx-3.0/wx/buffer.h|242|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token|
/usr/include/wx-3.0/wx/buffer.h|246|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token|
/usr/include/wx-3.0/wx/buffer.h|360|error: unknown type name ‘class’|
/usr/include/wx-3.0/wx/buffer.h|360|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token|
/usr/include/wx-3.0/wx/buffer.h|380|error: unknown type name ‘class’|
/usr/include/wx-3.0/wx/buffer.h|380|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token|
/usr/include/wx-3.0/wx/buffer.h|398|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token|
/usr/include/wx-3.0/wx/buffer.h|416|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token|
/usr/include/wx-3.0/wx/buffer.h|417|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token|
/usr/include/wx-3.0/wx/buffer.h|446|error: unknown type name ‘class’|
/usr/include/wx-3.0/wx/buffer.h|447|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
/usr/include/wx-3.0/wx/buffer.h|518|error: unknown type name ‘class’|
/usr/include/wx-3.0/wx/buffer.h|519|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
/usr/include/wx-3.0/wx/strconv.h|29|error: unknown type name ‘class’|
/usr/include/wx-3.0/wx/strconv.h|47|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|47|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|47|error: expected ‘,’ or ‘;’ before ‘wxMBConv’|
/usr/include/wx-3.0/wx/strconv.h|183|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|183|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|183|error: expected ‘,’ or ‘;’ before ‘wxMBConvLibc’|
/usr/include/wx-3.0/wx/strconv.h|205|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|205|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|205|error: expected ‘,’ or ‘;’ before ‘wxConvBrokenFileNames’|
/usr/include/wx-3.0/wx/strconv.h|251|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|251|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|251|error: expected ‘,’ or ‘;’ before ‘wxMBConvUTF7’|
/usr/include/wx-3.0/wx/strconv.h|341|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|341|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|341|error: expected ‘,’ or ‘;’ before ‘wxMBConvStrictUTF8’|
/usr/include/wx-3.0/wx/strconv.h|360|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|360|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|360|error: expected ‘,’ or ‘;’ before ‘wxMBConvUTF8’|
/usr/include/wx-3.0/wx/strconv.h|393|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|393|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|393|error: expected ‘,’ or ‘;’ before ‘wxMBConvUTF16Base’|
/usr/include/wx-3.0/wx/strconv.h|412|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|412|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|412|error: expected ‘,’ or ‘;’ before ‘wxMBConvUTF16LE’|
/usr/include/wx-3.0/wx/strconv.h|426|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|426|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|426|error: expected ‘,’ or ‘;’ before ‘wxMBConvUTF16BE’|
/usr/include/wx-3.0/wx/strconv.h|440|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|440|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|440|error: expected ‘,’ or ‘;’ before ‘wxMBConvUTF32Base’|
/usr/include/wx-3.0/wx/strconv.h|458|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|458|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|458|error: expected ‘,’ or ‘;’ before ‘wxMBConvUTF32LE’|
/usr/include/wx-3.0/wx/strconv.h|472|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|472|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|472|error: expected ‘,’ or ‘;’ before ‘wxMBConvUTF32BE’|
/usr/include/wx-3.0/wx/strconv.h|488|warning: data definition has no type or storage class|
/usr/include/wx-3.0/wx/strconv.h|488|warning: type defaults to ‘int’ in declaration of ‘class’ [-Wimplicit-int]|
/usr/include/wx-3.0/wx/strconv.h|488|error: expected ‘,’ or ‘;’ before ‘wxCSConv’|
/usr/include/wx-3.0/wx/strconv.h|576|error: unknown type name ‘wxMBConv’|
/usr/include/wx-3.0/wx/dlimpexp.h|116|note: in definition of macro ‘WXDLLIMPEXP_DATA_BASE’|
/usr/include/wx-3.0/wx/strconv.h|576|note: in expansion of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|576|error: unknown type name ‘wxMBConv’|
/usr/include/wx-3.0/wx/strconv.h|565|note: in definition of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|566|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘&’ token|
/usr/include/wx-3.0/wx/strconv.h|576|note: in expansion of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|580|error: unknown type name ‘wxCSConv’|
/usr/include/wx-3.0/wx/dlimpexp.h|116|note: in definition of macro ‘WXDLLIMPEXP_DATA_BASE’|
/usr/include/wx-3.0/wx/strconv.h|580|note: in expansion of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|580|error: unknown type name ‘wxCSConv’|
/usr/include/wx-3.0/wx/strconv.h|565|note: in definition of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|566|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘&’ token|
/usr/include/wx-3.0/wx/strconv.h|580|note: in expansion of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|583|error: unknown type name ‘wxMBConvStrictUTF8’|
/usr/include/wx-3.0/wx/dlimpexp.h|116|note: in definition of macro ‘WXDLLIMPEXP_DATA_BASE’|
/usr/include/wx-3.0/wx/strconv.h|583|note: in expansion of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|583|error: unknown type name ‘wxMBConvStrictUTF8’|
/usr/include/wx-3.0/wx/strconv.h|565|note: in definition of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|566|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘&’ token|
/usr/include/wx-3.0/wx/strconv.h|583|note: in expansion of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|586|error: unknown type name ‘wxMBConvUTF7’|
/usr/include/wx-3.0/wx/dlimpexp.h|116|note: in definition of macro ‘WXDLLIMPEXP_DATA_BASE’|
/usr/include/wx-3.0/wx/strconv.h|586|note: in expansion of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|586|error: unknown type name ‘wxMBConvUTF7’|
/usr/include/wx-3.0/wx/strconv.h|565|note: in definition of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|566|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘&’ token|
/usr/include/wx-3.0/wx/strconv.h|586|note: in expansion of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|596|error: unknown type name ‘wxMBConv’|
/usr/include/wx-3.0/wx/dlimpexp.h|116|note: in definition of macro ‘WXDLLIMPEXP_DATA_BASE’|
/usr/include/wx-3.0/wx/strconv.h|603|error: unknown type name ‘wxMBConv’|
/usr/include/wx-3.0/wx/dlimpexp.h|116|note: in definition of macro ‘WXDLLIMPEXP_DATA_BASE’|
/usr/include/wx-3.0/wx/strconv.h|606|error: unknown type name ‘wxCSConv’|
/usr/include/wx-3.0/wx/dlimpexp.h|116|note: in definition of macro ‘WXDLLIMPEXP_DATA_BASE’|
/usr/include/wx-3.0/wx/strconv.h|606|note: in expansion of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|606|error: unknown type name ‘wxCSConv’|
/usr/include/wx-3.0/wx/strconv.h|565|note: in definition of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|566|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘&’ token|
/usr/include/wx-3.0/wx/strconv.h|606|note: in expansion of macro ‘WX_DECLARE_GLOBAL_CONV’|
/usr/include/wx-3.0/wx/strconv.h|613|error: unknown type name ‘wxMBConv’|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 error(s), 28 warning(s) (0 minute(s), 0 second(s)) ===|
--- End code ---
Am I getting all of these errors because I'm adding sqlite3.c to mix in with the *.cpp files?
I just want to know how to use SQLite3 with a C::B GUI. That's all! Help me get this sorted out and I'll get out of your hair for life. I've been fighting this for over a month. Haven't said a word here because those here who know how to do things are already stretched thin as hell. And I'm not talking abt queries and stuff like that. I can do sql. I just want to know how to access SQLite3 in a C::B GUI.
stahta01:
Post an link to wxSQLite sample code; and, I might get a chance in the next week to figure it out.
Tim S.
Landslyde:
Hi stahta01:
I run Linux. I think wxSQLite3 might just be a wrapper for Windows. When I tried to use it, I recall it used *.dll files. But I might be wrong on it being strictly for Windows. I hope I am. Anyway, here are a few links:
https://www.youtube.com/watch?v=KHjSiVQbvX0
https://github.com/utelle/wxsqlite3
https://en.wikipedia.org/wiki/WxSQLite3
https://forums.wxwidgets.org/viewtopic.php?t=37675
If wxSQLite3 is a Windows-only SQLite3 wrapper for C++, then how can SQLite3 be used in a C::B GUI on Linux? I use SQLite3 in C::B console programs. That's easy. But when I try to use the same SQLite3 files in a C::B GUI, all hell breaks loose!
I hope you can figure this out. I sure can't. And thank you for trying. Than you very much for that.
New Pagodi:
I'm pretty sure wxSqlite has been dead for over a decade. Use wxSqlite3 instead.
Just build and install the library according to the instructions.
Here's a minimal example that only opens a database (or creates one if it doesn't exist). Create an empty wxWidgets project, add an empty cpp source file and paste this into it:
--- Code: ---// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <wx/wxsqlite3.h>
class MyFrame : public wxFrame
{
public:
MyFrame( wxWindow* parent, int id = wxID_ANY, wxString title = "Demo",
wxPoint pos = wxDefaultPosition, wxSize size = wxDefaultSize,
int style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
~MyFrame();
private:
wxSQLite3Database db;
};
MyFrame::MyFrame( wxWindow* parent, int id, wxString title, wxPoint pos,
wxSize size, int style )
:wxFrame( parent, id, title, pos, size, style )
{
db.Open("data.db");
if(db.IsOpen())
{
SetTitle("db opened");
}
}
MyFrame::~MyFrame()
{
if(db.IsOpen())
{
db.Close();
}
}
class MyApp : public wxApp
{
public:
virtual bool OnInit()
{
MyFrame* frame = new MyFrame(NULL);
frame->Show();
return true;
}
};
wxIMPLEMENT_APP(MyApp);
--- End code ---
Add the wxSqlite3 library to the code::blocks projects link libraries the build and run.
Landslyde:
Hi New Pagodi:
Works like a charm! A million thanks for your help.
Navigation
[0] Message Index
Go to full version