Bart Verstraete schreef:
>
> Warren Young schreef:
>> Bart Verstraete wrote:
>>>
>>> mysqlpp::longlong id = (mysqlpp::longlong)row["id"];
>>
>> The casts aren't necessary. Or if they are, it means the implicit
>> conversion rules aren't working, which would be a bug.
>>
>>> double total = (double)row["total"] //Throws an exception: Tried to
>>> convert "6.3000" to a "d
>>
>> In that case, many of the examples should be showing the same
>> symptom, because they do essentially this same thing. It works fine
>> here on my main GCC/Linux development system.
>>
>> So, try the examples. If they fail there, I think the problem may be
>> that your compiler isn't smart enough to create ColData::conv(double)
>> and so is falling back to the default definition of conv() which only
>> works for things that look sufficiently like integers. We'll need to
>> know your compiler and platform to be able to test any fix that may
>> be required.
>>
>> If the examples work but your program doesn't, you've got something
>> very weird going on.
>>
>> Once you sort all this out, consider using mysqlpp::sql_decimal
>> instead of double. They're typedef'd to the same thing, but may not
>> be forever. This type is a good candidate for a specialized
>> replacement because DECIMAL is a fixed-point type, so double isn't
>> the best match. We really should have something in the mold of
>> mysqlpp::tiny_int here.
> Hi,
>
> I removed the CASTS like you said, and it works. So my compiler is
> smart enough, ;-). But I still get that exception thrown with the
> coversion from DECIMAL to DOUBLE.
> I use:
> Ubuntu 7.10 i386
> Code::blocks (nightly build)
> GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
> for the GUI lib I use wxWidgets 2.8.7
>
> I also have another problem, when a table with VARCHAR returns fields
> with 1, 2, 4, 5, ... chars it got displayed well in my wxWidgets app.
> But when it returns a varchar with 3 chars it don't get displayed but
> when I output it to the console via std::cerr, the output is correct.
> I convert the mysqlpp::cchar* to a wxString
>
Damn got something strange now. Here is some example code:
void lfDbStaticText::SetLabel(mysqlpp::Null<mysqlpp::cchar*>& label) {
#ifdef DEBUG
std::cerr << label << std::endl;
std::string testlabel = (label.is_null ? "" : std::string(label));
// <-this is strange
#endif //DEBUG
wxString str = wxEmptyString;
if(!label.is_null) {
str = wxString(label, wxConvUTF8);
}
wxStaticText::SetLabel(str);
}
If I compile my app with the line where the comment is '<- this is
strange', wxString converts the cchar* good, but if I compile it without
wxString can't convert it. It is as if it don't find the '\0' char .
>
> Sorry for the late response.
>
>
> Grts Bart
>
| Thread |
|---|
| • Troubles wit DECIMAL(12,4) | Bart Verstraete | 23 Dec |
| • Re: Troubles wit DECIMAL(12,4) | Warren Young | 26 Dec |
| • Re: Troubles wit DECIMAL(12,4) | Bart Verstraete | 4 Jan |
| • Re: Troubles wit DECIMAL(12,4) | Bart Verstraete | 4 Jan |
| • RE: Troubles wit DECIMAL(12,4) | Joel Fielder | 4 Jan |
| • Re: Troubles wit DECIMAL(12,4) | Bart Verstraete | 4 Jan |
| • RE: Troubles wit DECIMAL(12,4) | Joel Fielder | 4 Jan |
| • Re: Troubles wit DECIMAL(12,4) | Bart Verstraete | 4 Jan |
| • Re: Troubles wit DECIMAL(12,4) | Warren Young | 4 Jan |
| • Re: Troubles wit DECIMAL(12,4) | Bart Verstraete | 4 Jan |
| • Re: Troubles wit DECIMAL(12,4) | Warren Young | 4 Jan |
| • Re: Troubles wit DECIMAL(12,4) | Bart Verstraete | 5 Jan |
| • Re: Troubles wit DECIMAL(12,4) | Jonathan Wakely | 5 Jan |
| • Re: Troubles wit DECIMAL(12,4) | Warren Young | 4 Jan |