Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Example code for CtrLib/Sqlite needed
Example code for CtrLib/Sqlite needed [message #5004] Wed, 30 August 2006 17:05 Go to next message
richardt is currently offline  richardt
Messages: 8
Registered: March 2006
Location: Germany
Promising Member
Does anybody have example code for a CtrLib/Sqlite app. Im trying to learn how to programm database applications with c++ and the only examples that I can find (books/tutorials) are console based. An example of how to use the dbf functionality of tcore within a CtrLib app. would also be most wellcome.

Thanks in advance for any help.

Richardt

Re: Example code for CtrLib/Sqlite needed [message #5012 is a reply to message #5004] Wed, 30 August 2006 19:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
richardt wrote on Wed, 30 August 2006 11:05

Does anybody have example code for a CtrLib/Sqlite app. Im trying to learn how to programm database applications with c++ and the only examples that I can find (books/tutorials) are console based. An example of how to use the dbf functionality of tcore within a CtrLib app. would also be most wellcome.

Thanks in advance for any help.

Richardt





Yes, something we plan to do for a long time, but are short of ideas...

The problem to solve has to be both simple not to push the sources to long and complex to show all possiblities.... And easily understandable at the same time. In a single word, trouble Wink

Mirek
Re: Example code for CtrLib/Sqlite needed [message #5034 is a reply to message #5012] Thu, 31 August 2006 18:58 Go to previous messageGo to next message
richardt is currently offline  richardt
Messages: 8
Registered: March 2006
Location: Germany
Promising Member
Thanks for the prompt reply Mirek. Actually,I was hoping that somebody out there would post a "Hello world" example for Sqlite and for dbf access. I can see from your forum contributions that you have other much more important priorities.

Once again, thanks.

BTW Super program and excellent forum.
Re: Example code for CtrLib/Sqlite needed [message #5035 is a reply to message #5012] Thu, 31 August 2006 20:04 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
luzr wrote on Wed, 30 August 2006 19:09


Yes, something we plan to do for a long time, but are short of ideas...

The problem to solve has to be both simple not to push the sources to long and complex to show all possiblities.... And easily understandable at the same time. In a single word, trouble Wink

Mirek


Yes, you are right. But, forgive me, any bad example, long and complex, is better than no example. So I invite the users that have done experiments with the above topics to make available something. U++ should show clearly its superiority even in the DB treatment and not only in the GUI design. I'm sure that after somebody will prepare a tutorial.

Luigi
Re: Example code for CtrLib/Sqlite needed [message #5361 is a reply to message #5035] Fri, 15 September 2006 22:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Now in changelog.

Mirek
Re: Example code for CtrLib/Sqlite needed [message #12774 is a reply to message #5004] Thu, 15 November 2007 14:42 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
But it is possible to make graphical database applications with U++, right?

Alex
Re: Example code for CtrLib/Sqlite needed [message #12775 is a reply to message #12774] Thu, 15 November 2007 15:16 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

See examples/HomeBuget.
Re: Example code for CtrLib/Sqlite needed [message #12826 is a reply to message #12775] Mon, 19 November 2007 17:34 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
HomeBudget project compiles and works fine!
But When I try to create my own GUI project:

File|Set Main Package|MyApps
New Package
HB (as package name)
CtrlLibApplication with main window
Create

And the HB project was generated in the MyApps. Then I copied the HomeBudget.sch to the MyApps\HB folder.

Now I look for the HomeBudget files and try to insert include files for sqlite in my app. Firstly on HD.h

#ifndef _HB_HB_h
#define _HB_HB_h

//ADDED BY ME
#include <CtrlLib/CtrlLib.h>
#include <plugin/sqlite3/lib/sqlite3.h>
#include <plugin/sqlite3/Sqlite3.h>

#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <HomeBudget.sch>
//END OF ADDED BY ME


#include <CtrlLib/CtrlLib.h>

using namespace Upp;
#define LAYOUTFILE <HB/HB.lay>
#include <CtrlCore/lay.h>

class HB : public WithHBLayout<TopWindow>
{
public:
typedef HB CLASSNAME;
HB();
};

#endif



When I paste these includes right next the //END OF ADDED BY ME comment:

#include <Sql/sch_schema.h>
#include <Sql/sch_header.h>
#include <Sql/sch_source.h>



I compile the application and some woarnings and erros appera. Here is the output:


----- CtrlLib ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (1 / 9)
----- CtrlCore ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (2 / 9)
----- RichText ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (3 / 9)
----- Draw ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (4 / 9)
----- Core ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (5 / 9)
----- plugin/bmp ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (6 / 9)
----- plugin\z ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (7 / 9)
----- plugin\png ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (8 / 9)
----- HB ( GUI MAIN GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (9 / 9)
main.cpp
In file included from C:/upp/uppsrc/Sql/sch_schema.h:24,
from C:\Upp\MyApps\HB\/HB.h:14,
from C:\Upp\MyApps\HB\main.cpp:1:
C:/upp/uppsrc/plugin/sqlite3/Sqlite3Schema.h:6:1: warning: "INT64" redefined
In file included from C:/upp/uppsrc/Core/Core.h:329,
from C:/upp/uppsrc/Draw/Draw.h:4,
from C:/upp/uppsrc/CtrlCore/CtrlCore.h:4,
from C:/upp/uppsrc/CtrlLib/CtrlLib.h:4,
from C:\Upp\MyApps\HB\/HB.h:4,
from C:\Upp\MyApps\HB\main.cpp:1:
C:/upp/uppsrc/Core/Defs.h:194:1: warning: this is the location of the previous definition
In file included from C:/upp/uppsrc/plugin/sqlite3/Sqlite3Schema.h:82,
from C:/upp/uppsrc/Sql/sch_schema.h:24,
from C:\Upp\MyApps\HB\/HB.h:14,
from C:\Upp\MyApps\HB\main.cpp:1:
C:/upp/uppsrc/Sql/sch_model.h:149:15: HomeBudget.sch: No such file or directory
In file included from C:\Upp\MyApps\HB\/HB.h:14,
from C:\Upp\MyApps\HB\main.cpp:1:
C:/upp/uppsrc/Sql/sch_schema.h:48: error: variable or field `All_Tables' declared void
C:/upp/uppsrc/Sql/sch_schema.h:48: error: `SqlSchema' was not declared in this scope
C:/upp/uppsrc/Sql/sch_schema.h:48: error: `schema' was not declared in this scope
C:/upp/uppsrc/Sql/sch_schema.h:48: error: expected `,' or `;' before '{' token
In file included from C:\Upp\MyApps\HB\main.cpp:1:
C:\Upp\MyApps\HB\/HB.h:37:7: warning: no newline at end of file
HB: 1 file(s) built in (0:05.78), 5781 msecs / file, duration = 5797 msecs

There were errors. (0:05.95)



Can you help me?


Alex
Re: Example code for CtrLib/Sqlite needed [message #12829 is a reply to message #12826] Mon, 19 November 2007 23:47 Go to previous messageGo to next message
Alex is currently offline  Alex
Messages: 18
Registered: October 2007
Location: Germany
Promising Member
Hi Alex,

Have a look at "examples/sqlapp".

#ifndef _HB_HB_h
#define _HB_HB_h

//ADDED BY ME
#include <CtrlLib/CtrlLib.h>
#include <plugin/sqlite3/Sqlite3.h>

using namespace Upp;

#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <hb/HomeBudget.sch>
// -----!!-----^^
#include <Sql/sch_header.h>
//END OF ADDED BY ME

#define LAYOUTFILE <HB/HB.lay>
#include <CtrlCore/lay.h>

class HB : public WithHBLayout<TopWindow> {
public:
	typedef HB CLASSNAME;
	HB();
};

#endif

Works with MSC8 Debug/Optimal.

HTH
Alex
Re: Example code for CtrLib/Sqlite needed [message #12837 is a reply to message #12829] Tue, 20 November 2007 18:18 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Hi Alex and Thank you!

Well, for me it works on optimal, speed and size. When compiling on DEBUG it presents the following errors. But for now it is ok for me. I will use the Optimal compilation.
By the way, why "using namespace Upp;" must be right next these includes?

//ADDED BY ME
#include <CtrlLib/CtrlLib.h>
#include <plugin/sqlite3/Sqlite3.h>


Another begginer question (sorry): why there is no need to inlude also

#include <Sql/sch_header.h>
#include <Sql/sch_source.h>

HomeBudget project includes them.

Thanks once again...

Alex



Errors while compiling in DEBUG:

----- CtrlLib ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (1 / 9)
----- CtrlCore ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (2 / 9)
----- RichText ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (3 / 9)
----- Draw ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (4 / 9)
----- Core ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (5 / 9)
----- plugin/bmp ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (6 / 9)
----- plugin\z ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (7 / 9)
----- plugin\png ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (8 / 9)
----- HB ( GUI MAIN GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (9 / 9)
main.cpp
In file included from C:/upp/uppsrc/Sql/sch_schema.h:24,
from C:\Upp\MyApps\HB\/HB.h:12,
from C:\Upp\MyApps\HB\main.cpp:1:
C:/upp/uppsrc/plugin/sqlite3/Sqlite3Schema.h:6:1: warning: "INT64" redefined
In file included from C:/upp/uppsrc/Core/Core.h:329,
from C:/upp/uppsrc/Draw/Draw.h:4,
from C:/upp/uppsrc/CtrlCore/CtrlCore.h:4,
from C:/upp/uppsrc/CtrlLib/CtrlLib.h:4,
from C:\Upp\MyApps\HB\/HB.h:5,
from C:\Upp\MyApps\HB\main.cpp:1:
C:/upp/uppsrc/Core/Defs.h:194:1: warning: this is the location of the previous definition
In file included from C:\Upp\MyApps\HB\main.cpp:1:
C:\Upp\MyApps\HB\/HB.h:26:7: warning: no newline at end of file
HB: 1 file(s) built in (0:05.11), 5110 msecs / file, duration = 5110 msecs
Linking...
(option '-O 2' ignored)
___main: duplicate
-> used: libmingw32.a:gccmain.o:1
-> discarded: libgcc.a:__main.o:1
3 undefined symbol(s):
Upp::SqlSchema::InlineAttribute(char const*)(referenced from c:\upp\out\hb\mingw.debug_full.gui.main\main.o:1; SCHE
MA_DATES(Upp::SqlSchema &); SCHEMA_DATES(Upp::SqlSchema&); SCHEMA_GROUPS(Upp::SqlSchema &); SCHEMA_GROUPS(Upp::
SqlSchema&); ...)
Upp::SqlSchema::Table(char const*)(referenced from c:\upp\out\hb\mingw.debug_full.gui.main\main.o:1; SCHEMA_DATES(U
pp::SqlSchema &); SCHEMA_DATES(Upp::SqlSchema&); SCHEMA_GROUPS(Upp::SqlSchema &); SCHEMA_GROUPS(Upp::SqlSchema&
); ...)
Upp::SqlSchema::Column(char const*, char const*)(referenced from c:\upp\out\hb\mingw.debug_full.gui.main\main.o:1;
SCHEMA_DATES(Upp::SqlSchema &); SCHEMA_DATES(Upp::SqlSchema&); SCHEMA_GROUPS(Upp::SqlSchema &); SCHEMA_GROUPS(U
pp::SqlSchema&); ...)
linking aborted due to fatal errors
collect2: ld returned 1 exit status

There were errors. (0:05.89)
Re: Example code for CtrLib/Sqlite needed [message #12882 is a reply to message #12837] Sat, 24 November 2007 20:44 Go to previous message
Alex is currently offline  Alex
Messages: 18
Registered: October 2007
Location: Germany
Promising Member
alex100 wrote on Tue, 20 November 2007 18:18

Another begginer question (sorry): why there is no need to inlude also

#include <Sql/sch_header.h>
#include <Sql/sch_source.h>

HomeBudget project includes them.



Unfortunately, I can not help. My experience with the sql, I made with try & error.

alex100 wrote on Tue, 20 November 2007 18:18


Errors while compiling in DEBUG:

3 undefined symbol(s):
Upp::SqlSchema::InlineAttribute(char const*)(referenced from c:\upp\out\hb\mingw.debug_full.gui.main\main.o:1; SCHE
MA_DATES(Upp::SqlSchema &); SCHEMA_DATES(Upp::SqlSchema&); SCHEMA_GROUPS(Upp::SqlSchema &);
...



Looks like, the package "plugin/sqlite2" is missing in your packages?

Alex
Previous Topic: Setting SQLite language?!
Next Topic: Create Table with Sqlite
Goto Forum:
  


Current Time: Fri Mar 29 06:38:31 CET 2024

Total time taken to generate the page: 0.01803 seconds