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 » Can not get a double from database
Can not get a double from database [message #17889] Mon, 01 September 2008 20:48 Go to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Hi,
I am trying to get a double (I think) from a sqlite3 database but I see a bad number. Ints and Strings no problem.
Here the code:

if(!SQL.Execute(Format("Select sum(ammount) from Pags where Num_Cli_Pag=%d",nNumCli)))
{
PromptOK("Error!");
}
if(!SQL.Fetch())
{
edDeb.SetData("0");
}
else
{
double d=(double)SQL[0];
strTemp=Format("%f",d);
edDeb.SetData(strTemp);
}

What am I doing wrong?

Thank you

Alex
Re: Can not get a double from database [message #18030 is a reply to message #17889] Sun, 07 September 2008 11:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kbyte wrote on Mon, 01 September 2008 14:48

Hi,
I am trying to get a double (I think) from a sqlite3 database but I see a bad number. Ints and Strings no problem.
Here the code:

if(!SQL.Execute(Format("Select sum(ammount) from Pags where Num_Cli_Pag=%d",nNumCli)))
{
PromptOK("Error!");
}
if(!SQL.Fetch())
{
edDeb.SetData("0");
}
else
{
double d=(double)SQL[0];
strTemp=Format("%f",d);
edDeb.SetData(strTemp);
}

What am I doing wrong?

Thank you

Alex


Well, a couple of things (using SQL for select, probably using EditString to edit double...), but nothing related to the problem.

Small testcase would help.

Mirek
Re: Can not get a double from database [message #18038 is a reply to message #18030] Sun, 07 September 2008 14:16 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
You should check the value coming from the database by outputting SQL[0] with Cout() (or use debugger).

Also, you could also skip the conversion and do:
edDeb.SetData(SQL[0]);


Also, is "ammount" supposed to be spelled "amount"?


Re: Can not get a double from database [message #18039 is a reply to message #18038] Sun, 07 September 2008 20:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
captainc wrote on Sun, 07 September 2008 08:16


Also, is "ammount" supposed to be spelled "amount"?



Well, that would explain the problem:)

(And, add to the list of things that are bad: Use SqlExp to avoid such problems Wink

Mirek
Re: Can not get a double from database [message #18069 is a reply to message #18039] Tue, 09 September 2008 13:19 Go to previous message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Forget it! Smile
Sometimes there is a problem on the nNumCli variable and it does not work for that.

Very sorry for this message and thank you for the attention to me

Alex

Previous Topic: SQL statment in constructor make program crash
Next Topic: MySql basic example
Goto Forum:
  


Current Time: Tue Apr 16 14:36:33 CEST 2024

Total time taken to generate the page: 0.01729 seconds