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 » Community » Newbie corner » Table is empty ?!
Table is empty ?! [message #41032] Tue, 22 October 2013 18:18 Go to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
hi all,
I have to check if my database tables are empty...
I wrote this control function:
bool Impostazioni::ControlloDatabase()
{
	int a,b;

	SQL * Select(ID_TIPOLEGNO).From(TIPOLOGIALEGNO);
	while(SQL.Fetch())
		a =	SQL[ID_TIPOLEGNO].GetCount();
		
	SQL * Select(ID_LEGNO).From(CLASSIRESISTENZALEGNO);
	while(SQL.Fetch())
		b =	SQL[ID_LEGNO].GetCount();
	
	if(a>0 || b>0)
		return true;
	else
		return false;	
}


it works but... I don't like it, someone can explain me a better solution ?

regards,
Matteo
Re: Table is empty ?! [message #41033 is a reply to message #41032] Tue, 22 October 2013 19:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
	SQL * Select(ID_TIPOLEGNO).From(TIPOLOGIALEGNO).Limit(1);
	if(SQL.Fetch()) "ID_TIPOLEGNO is not empty"


[Updated on: Tue, 22 October 2013 19:32]

Report message to a moderator

Re: Table is empty ?! [message #41043 is a reply to message #41033] Wed, 23 October 2013 21:33 Go to previous message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member

well done, ty mirek !

[Updated on: Wed, 23 October 2013 21:33]

Report message to a moderator

Previous Topic: Confused about ArrayCtrl
Next Topic: Reporto to rtf or doc format
Goto Forum:
  


Current Time: Tue Apr 16 17:38:53 CEST 2024

Total time taken to generate the page: 0.01420 seconds