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 » How to save the DB data to another SQLite db file in HomeBudget?
How to save the DB data to another SQLite db file in HomeBudget? [message #14392] Mon, 25 February 2008 04:22 Go to next message
fuqr is currently offline  fuqr
Messages: 16
Registered: July 2007
Location: Singapore
Promising Member
Hi,
In HomeBudget example, the DB data file is fixed & named as "HomeBudget.db3". How I can add an option or THISBACK(DbSaveAs) to save it as a db file which name can be assigned freely?

Thanks in advance,
Smile
Re: How to save the DB data to another SQLite db file in HomeBudget? [message #14434 is a reply to message #14392] Tue, 26 February 2008 16:38 Go to previous messageGo to next message
bytefield is currently offline  bytefield
Messages: 210
Registered: December 2007
Experienced Member
To make a SaveAs menu and save the DB with another name is easy.
Just add a menu to HomeBudgetLayout, connect it with SaveAs callback, which contain something like
FileSel fsel;
if(fsel.ExecuteSaveAs(t_("Save Database As...")))
{
	if(FileExists(DB_file)) // DB_file is current DB name
	{
		if(FileCopy(DB_file, fsel.Get()))
			DB_file = fsel.Get();
		else
			PromptOK("Error saving file!");
	}
}


The hard (not so hard Confused ) part is if you want to make HomeBudget to load last DB, because of it current implementation which create DB session in GUI_APP_MAIN. You can do what you want with current implementation but must do a lot of test to see if current DB exist, you may move the creation of hb instance(from main), up, before DB initialization to use HomeBudget Serialize and get last DB file name from configuration file.
Or you may remake some part of HomeBudget and move somehow the DB initialization in HomeBudget Setup.
There are others alternatives, Just try. Or if you are a newbie (like me) try simple things until have the knowledge to do advanced stuff.


cdabbd745f1234c2751ee1f932d1dd75
Re: How to save the DB data to another SQLite db file in HomeBudget? [message #14512 is a reply to message #14392] Thu, 28 February 2008 03:23 Go to previous message
fuqr is currently offline  fuqr
Messages: 16
Registered: July 2007
Location: Singapore
Promising Member
Thanks bytefield,
You are right the problem is the DB session is created in GUI_APP_MAIN.
Acturaly what I tried is the following:(simple way Smile )
===============================================
String filenameas; // I put in global variable: *.h

void HomeBudget::DbSaveAs()
{
FileSel fsas;
fsas.ActiveDir(GetCurrentDirectory());
fsas.Type("db3", "*.db3");
if(fsas.ExecuteSaveAs()
{
if(FileExists(filenameas))
......
}
}

GUI_APP_MAIN
{
......
String filename = fs;
FileIn fi(filename);
filenameas = filename; // failed line ???
......
}
===================================================
To open different DB file I didn't use *.cfg file.
Thanks for your help!


Previous Topic: Can't fetch row...
Next Topic: Table field name conflict?
Goto Forum:
  


Current Time: Thu Apr 25 02:04:42 CEST 2024

Total time taken to generate the page: 0.02432 seconds