I'm using SQL Server for the first time for a web site back-end and
I'm having problems with numbers. I have a field that accepts numbers
(the data type is float). When a user submits a value like 159,000 it
causes an error. When they enter 159000 it does not. Is this normal?
Thanks.
BrettBrett_A,
Yes, it is normal. The thousands separator is not considered part of the
number.
AMB
"Brett_A" wrote:
> I'm using SQL Server for the first time for a web site back-end and
> I'm having problems with numbers. I have a field that accepts numbers
> (the data type is float). When a user submits a value like 159,000 it
> causes an error. When they enter 159000 it does not. Is this normal?
> Thanks.
> Brett
>|||Is there a different data type I should be using to allow this or
should I just write some ASP that strips the separator out of the
string on form submission?
Thanks
Brett
On Jun 28, 10:26 am, Alejandro Mesa
<AlejandroM...@.discussions.microsoft.com> wrote:[vbcol=seagreen]
> Brett_A,
> Yes, it is normal. The thousands separator is not considered part of the
> number.
> AMB
> "Brett_A" wrote:
>
>|||If I understand you correcctly, you have a web application that accept user
input and pass the data to SQL Server. It is obviously the front end (web
app)'s responsibility to validate the user input. You cannot just take
whatever user enters and dump it into SQL Server database. For example, if
you have a text box on a web page, anything user enteres is considered as
text type. You need to convert it into a type you expected (Integer,
Double... or String). Say, what if user enters 159ooo (character O, not
zero)?
"Brett_A" <brettatkin@.gmail.com> wrote in message
news:1183038988.213278.276160@.u2g2000hsc.googlegroups.com...
> I'm using SQL Server for the first time for a web site back-end and
> I'm having problems with numbers. I have a field that accepts numbers
> (the data type is float). When a user submits a value like 159,000 it
> causes an error. When they enter 159000 it does not. Is this normal?
> Thanks.
> Brett
>|||No, there's not a separate datatype for this. Think about it, there could be
a plethora of ways to
represent such a number, including different separators like dot and comma a
nd also spaces. You
don't want SQL Server to have like several hundred of datatypes (multiply no
w many numerical
datatypes we have with possible ways of representing the number). So, you ne
ed to make sure that the
app submits a value that SQL Server understands. In fact, you should never r
epresent the number as a
string in the first place. Use command object and parameter objects and now
you can bind your client
app variable directly without going though some string representation.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Brett_A" <brettatkin@.gmail.com> wrote in message
news:1183042048.295884.19880@.k79g2000hse.googlegroups.com...
> Is there a different data type I should be using to allow this or
> should I just write some ASP that strips the separator out of the
> string on form submission?
> Thanks
> Brett
>
> On Jun 28, 10:26 am, Alejandro Mesa
> <AlejandroM...@.discussions.microsoft.com> wrote:
>
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment