Subject | Re: [firebird-support] Save decimal data type |
---|---|
Author | André Knappstein |
Post date | 2013-05-29T16:48:43Z |
Francisco,
did you carefully read all of my message and the examples I posted?
Sorry to ask, but I don't have the impression you did.
What you experience probably is working as designed. At least probably
"as designed by Microsoft" (for .net providers).
_IF_ you are using the FbParameters collection correctly, declaring
the FbParameters["@MyParamName"].Type as "Decimal", _AND_ provide a
decimal value to the FbParameters["@MyParamName"].Value, everything
will work fine, I am quite sure.
Your example does not contain *any* parameter (it simply misses any
"@", which is required to introduce a parameter in .net).
Please try again.
If it does not work, please post a more complete part of your code,
and please better use the list "Firebird-net-provider" to not bother
the non-net users. I am sure that memberst of that list will be able
to help you very quickly!
best regards,
André
André Knappstein
EDV und Controlling
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
beta Eigenheim- und Grundstücksverwertungsgesellschaft mbH
Hafenweg 4
59192 Bergkamen-Rünthe
Telefon: +49 2389 9240 140
Telefax: +49 2389 9240 150
e-mail: knappstein@...
Amtsgericht Hamm Nr. B 420
Geschäftsführer: Achim Krähling, Dirk Salewski und Matthias Steinhaus
USt-IDNr.: DE 125215402
did you carefully read all of my message and the examples I posted?
Sorry to ask, but I don't have the impression you did.
What you experience probably is working as designed. At least probably
"as designed by Microsoft" (for .net providers).
_IF_ you are using the FbParameters collection correctly, declaring
the FbParameters["@MyParamName"].Type as "Decimal", _AND_ provide a
decimal value to the FbParameters["@MyParamName"].Value, everything
will work fine, I am quite sure.
Your example does not contain *any* parameter (it simply misses any
"@", which is required to introduce a parameter in .net).
Please try again.
If it does not work, please post a more complete part of your code,
and please better use the list "Firebird-net-provider" to not bother
the non-net users. I am sure that memberst of that list will be able
to help you very quickly!
best regards,
André
> Thanks André;mit freundlichen Grüßen,
> I've declarated the FbConnection, and FbCommand.
> Everything works fine with connection and Command.
> If I send a Query like this:
> SQLString = "INSERT INTO MyTable(CANT) VALUES(MyAmount)"
> considering the Field CANT as String, and the same thing for MyAmount,
> FireBird has no problem to save the data.
> the problem is, when CANT is Decimal data type, or Numeric, or Float.
> Any one?
> How to save a decimal data type in Firebird from an app??
> doesn't matter if the programming languaje is other than VB.Net
> I need to know how to save a decimal data into firebird like this: 25.80
> thanks
>
> Francisco José Scheffer
> ________________________________
> De: André Knappstein <Knappstein@...>
> Para: Francisco José Scheffer <firebird-support@yahoogroups.com>
> Enviado: miércoles, 29 de mayo de 2013 10:35
> Asunto: Re: [firebird-support] Save decimal data type
>
>
> Francisco,
> to me this does not look like proper code for .net.
> Personally I am using C#, but I know quite some of VB.net.
> You need:
> - a Command object (of Type FbCommand)
> - a Parameter object (of Typ FbParameter)
> look at the following links for further guidance to VB.net in this
> regard:
> http://www.dreamincode.net/forums/topic/165141-sql-parameters-from-vbnet/
> http://idealprogrammer.com/net-languages/code-samples/vbnet-sql-parameters-source-code-insert-statement/
> http://www.java2s.com/Code/VB/Database-ADO.net/PassParameterintoSQLcommand.htm
> Have fun!
>> thanks Ann;
>> Here is some code;
>> Declaration
>> Dim MyAmount as Double /* Double - 64 bit floating-point number */
>> Dim SQLString as String
>> MyAmount = 25.80
>> SQLString = "INSERT INTO MyTable(CANT) VALUES(MyAmount)"
>> In Firebird, the field CANT is: (I've tried Numeric, Decimal and FLOAT also)
>> With Decimal was 18,4
>> Numeric was 12,2
>> When Firebird save the data, it does as 2580, not 25.80;
>> Is it perhaps a problem on my Windows regional settings?
>> thanks for help!!
>> Francisco José Scheffer
>> ________________________________
>> De: Ann Harrison <aharrison@...>
>> Para: firebird-support@yahoogroups.com
>> Enviado: martes, 28 de mayo de 2013 17:36
>> Asunto: Re: [firebird-support] Save decimal data type
>> On Tue, May 28, 2013 at 10:26 AM, franchessko <scheffer74@...> wrote:
>>> Hi, I'm a new firebird user. I joined here to ask for help.
>>> I develop in DotNet Technologies, and I have this problem:
>>>
>>>
>>> And the problem is:
>>> -------------------
>>> When I send a Query with a decimal data type like '25.80' -without quotes-
>>> the data is saved in firebird like this 2580,0000
>>> (the database field was created as Decimal 18,4)
>>>
>> Without seeing the actual queries you used, I'm guessing about why you see
>> what you see, but I can tell you what Firebird is doing. When you store
>> 25.80 in a column that's defined as decimal 18,4, Firebird stores the
>> value as in integer, which in this case would be 258000 (two hundred fifty
>> eight thousand). The scale is part of the field definition. Firebird uses
>> the scale when doing comparisons, so 258000 scale 4 is more than 2570000
>> scale 5 and less than 260 scale 1. All that is fine, internally.
>> However, the SQL numeric and decimal types are based on data types used in
>> COBOL. Those data types are not generally supported in more modern
>> languages. When you retrieve a decimal or numeric value with a non-zero
>> scale, you should probably ask for it as a floating point number or a
>> string. You'll get better information from the Firebird .NET driver list
>> on exactly how to push decimal and numeric values through that interface.
>>> I tried sending the same number, but with the comma '25,80' but firebird
>>> says: "Dynamic SQL Error. SQL Error code = -804. Count of read-write
>>> columns does not equal count of values"
>>>
>> Firebird does not use the locale to choose the separator between the
>> integral and decimal portions of a number, so it's reading 25,80 as two
>> values 25 and 80.
>> Good luck,
>> Ann
>> [Non-text portions of this message have been removed]
>>
>> ------------------------------------
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> Visit http://www.firebirdsql.org and click the Resources item
>> on the main (top) menu. Try Knowledgebase and FAQ links !
>> Also search the knowledgebases at http://www.ibphoenix.com
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> Yahoo! Groups Links
> mit freundlichen Grüßen,
> André Knappstein
> EDV und Controlling
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> beta Eigenheim- und Grundstücksverwertungsgesellschaft mbH
> Hafenweg 4
> 59192 Bergkamen-Rünthe
> Telefon: +49 2389 9240 140
> Telefax: +49 2389 9240 150
> e-mail: knappstein@...
> Amtsgericht Hamm Nr. B 420
> Geschäftsführer: Achim Krähling, Dirk Salewski und Matthias Steinhaus
> USt-IDNr.: DE 125215402
>
> [Non-text portions of this message have been removed]
> ------------------------------------
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
> Also search the knowledgebases at http://www.ibphoenix.com
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
André Knappstein
EDV und Controlling
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
beta Eigenheim- und Grundstücksverwertungsgesellschaft mbH
Hafenweg 4
59192 Bergkamen-Rünthe
Telefon: +49 2389 9240 140
Telefax: +49 2389 9240 150
e-mail: knappstein@...
Amtsgericht Hamm Nr. B 420
Geschäftsführer: Achim Krähling, Dirk Salewski und Matthias Steinhaus
USt-IDNr.: DE 125215402