Type mismatch error between SQL Money format and Web Cookie value
Type mismatch error between SQL Money format and Web Cookie value
am 01.03.2006 15:43:29 von GLKGail
I am working on an application that allows the entry of a product
specification maintained in SQL 7.0 through a Web Page using ASP. There are
four fields in the SQL database that are set to the format "money" since they
represent monetary charges for special services. The amount of data to be
entered into the specification is pretty large and somewhat varried,
depending on the labeling needed. So the data entry form is a series of 6
webpages where the form data is maintained in cookies until all forms have
been completed. Then a "save" script runs to create a new record and update
the database tables involved. I am just doing a simple assignment of the
cookie value to the record set value. One of the monetary fields reads like
this:
rsNewSpec("colorcharge") = Request.Cookies("ContColorChgAmt")
When I run the application, I am getting a type mismatch error on this line.
Provider error # is 80020005. I have surmised that it is caused by the money
formatted field in SQL since, if I change the field type to character data,
the assignment proceeds as intended. I tried using the VBscript currency
conversion function as follows:
rsNewSpec("colorcharge") = CCur(Request.Cookies("ContColorChgAmt")
With this, I get a VBScript runtime error '800a00d' type mismatch 'CCur'
error. According to my reference book, this function uses either numeric or
text data. If I test for IsNumeric, the test fails eventhough the data is
0.15 which I verified by printing to the page directly from the cookie.
Is there anything I can do so that I can continue to use the monetary format
in my SQL database? Thanks in advance. -- Gail
Re: Type mismatch error between SQL Money format and Web Cookie value
am 02.03.2006 02:47:55 von unknown
Have you looked at what Request.Cookies("ContColorChgAmt") is?
Response.Write Request.Cookies("ContColorChgAmt")
Response.End
You should be validating all user input.
Also, instead of creating an adodb.recordset, setting field values, and all
that, I suggest you run an INSERT command instead.
http://www.aspfaq.com/show.asp?id=2191
Ray at home
"GLKGail" wrote in message
news:90AE4DB7-9E06-4808-9C38-6A5CAF6CEB40@microsoft.com...
>I am working on an application that allows the entry of a product
> specification maintained in SQL 7.0 through a Web Page using ASP. There
> are
> four fields in the SQL database that are set to the format "money" since
> they
> represent monetary charges for special services. The amount of data to be
> entered into the specification is pretty large and somewhat varried,
> depending on the labeling needed. So the data entry form is a series of 6
> webpages where the form data is maintained in cookies until all forms have
> been completed. Then a "save" script runs to create a new record and
> update
> the database tables involved. I am just doing a simple assignment of the
> cookie value to the record set value. One of the monetary fields reads
> like
> this:
>
> rsNewSpec("colorcharge") = Request.Cookies("ContColorChgAmt")
>
Re: Type mismatch error between SQL Money format and Web Cookie va
am 02.03.2006 16:28:39 von GLKGail
Yes, I did a response.write to the next page. "0.15" was displayed. I'm using
Front Page 2002 to design and I initially had the field validated as numeric.
Data entry did not trigger an error message. When I check data using
IsNumeric, it fails, even though the data is visually numeric. It's as if the
cookie is causing it to read as text only.
I'll take a look at the faq you suggest. This is my first attempt at this
type of application. I've been learning as I go, so it does not surprise me
at all that there is a better, efficient way to do this. I created a new
record in the record set, then used a Update command to add it to the table.
Thanks for the advice.
Gail
"Ray Costanzo [MVP]" wrote:
> Have you looked at what Request.Cookies("ContColorChgAmt") is?
>
> Response.Write Request.Cookies("ContColorChgAmt")
> Response.End
>
> You should be validating all user input.
>
> Also, instead of creating an adodb.recordset, setting field values, and all
> that, I suggest you run an INSERT command instead.
> http://www.aspfaq.com/show.asp?id=2191
>
> Ray at home
>
> "GLKGail" wrote in message
> news:90AE4DB7-9E06-4808-9C38-6A5CAF6CEB40@microsoft.com...
> >I am working on an application that allows the entry of a product
> > specification maintained in SQL 7.0 through a Web Page using ASP. There
> > are
> > four fields in the SQL database that are set to the format "money" since
> > they
> > represent monetary charges for special services. The amount of data to be
> > entered into the specification is pretty large and somewhat varried,
> > depending on the labeling needed. So the data entry form is a series of 6
> > webpages where the form data is maintained in cookies until all forms have
> > been completed. Then a "save" script runs to create a new record and
> > update
> > the database tables involved. I am just doing a simple assignment of the
> > cookie value to the record set value. One of the monetary fields reads
> > like
> > this:
> >
> > rsNewSpec("colorcharge") = Request.Cookies("ContColorChgAmt")
> >
>
>
Re: Type mismatch error between SQL Money format and Web Cookie va
am 04.03.2006 05:56:23 von Roland Hall
"GLKGail" wrote in message
news:2824DAF5-4208-45A8-84E8-8D3DA51A8156@microsoft.com...
: Yes, I did a response.write to the next page. "0.15" was displayed. I'm
using
: Front Page 2002 to design and I initially had the field validated as
numeric.
: Data entry did not trigger an error message. When I check data using
: IsNumeric, it fails, even though the data is visually numeric. It's as if
the
: cookie is causing it to read as text only.
:
: I'll take a look at the faq you suggest. This is my first attempt at this
: type of application. I've been learning as I go, so it does not surprise
me
: at all that there is a better, efficient way to do this. I created a new
: record in the record set, then used a Update command to add it to the
table.
Hi Gail...
If you want to know what a variable type is, use: Response.Write
typename(var)
IsNumeric is not a very good test.
You may be testing a string against a double. You can always convert it.
CDbl(var)
There is no reason to create a recordset to insert a record into a database.
Ray's suggestion to use INSERT INTO, IMO, is the better method. And, a
stored procedure is preferred over dynamic SQL, for numerous reasons, speed,
modularity, security, etc.
If you reply after posts, instead of on top of them, nobody has to read
every part of the thread to follow along with the conversation.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Re: Type mismatch error between SQL Money format and Web Cookie va
am 07.03.2006 15:58:28 von GLKGail
"Roland Hall" wrote:
> "GLKGail" wrote in message
> news:2824DAF5-4208-45A8-84E8-8D3DA51A8156@microsoft.com...
> : Yes, I did a response.write to the next page. "0.15" was displayed. I'm
> using
> : Front Page 2002 to design and I initially had the field validated as
> numeric.
> : Data entry did not trigger an error message. When I check data using
> : IsNumeric, it fails, even though the data is visually numeric. It's as if
> the
> : cookie is causing it to read as text only.
> :
> : I'll take a look at the faq you suggest. This is my first attempt at this
> : type of application. I've been learning as I go, so it does not surprise
> me
> : at all that there is a better, efficient way to do this. I created a new
> : record in the record set, then used a Update command to add it to the
> table.
>
> Hi Gail...
>
> If you want to know what a variable type is, use: Response.Write
> typename(var)
> IsNumeric is not a very good test.
>
> You may be testing a string against a double. You can always convert it.
> CDbl(var)
>
> There is no reason to create a recordset to insert a record into a database.
> Ray's suggestion to use INSERT INTO, IMO, is the better method. And, a
> stored procedure is preferred over dynamic SQL, for numerous reasons, speed,
> modularity, security, etc.
>
> If you reply after posts, instead of on top of them, nobody has to read
> every part of the thread to follow along with the conversation.
>
> --
> Roland Hall
> /* This information is distributed in the hope that it will be useful, but
> without any warranty; without even the implied warranty of merchantability
> or fitness for a particular purpose. */
> Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
> WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
> MSDN Library - http://msdn.microsoft.com/library/default.asp
>
>
>
Roland,
Will try to remember to reply "under". I tried the typename function to
check the data type. Everything is showing as IReadCookie type. I tried this
on both numeric as well as text. Is this a standard cookie type of data that
I need to convert? That will be my next step. I'm writing the insert
statement right now so I don't have to use a record set. Thanks for all the
help!
Gail
Re: Type mismatch error between SQL Money format and Web Cookie va
am 07.03.2006 17:52:53 von GLKGail
"GLKGail" wrote:
>
>
> "Roland Hall" wrote:
>
> > "GLKGail" wrote in message
> > news:2824DAF5-4208-45A8-84E8-8D3DA51A8156@microsoft.com...
> > : Yes, I did a response.write to the next page. "0.15" was displayed. I'm
> > using
> > : Front Page 2002 to design and I initially had the field validated as
> > numeric.
> > : Data entry did not trigger an error message. When I check data using
> > : IsNumeric, it fails, even though the data is visually numeric. It's as if
> > the
> > : cookie is causing it to read as text only.
> > :
> > : I'll take a look at the faq you suggest. This is my first attempt at this
> > : type of application. I've been learning as I go, so it does not surprise
> > me
> > : at all that there is a better, efficient way to do this. I created a new
> > : record in the record set, then used a Update command to add it to the
> > table.
> >
> > Hi Gail...
> >
> > If you want to know what a variable type is, use: Response.Write
> > typename(var)
> > IsNumeric is not a very good test.
> >
> > You may be testing a string against a double. You can always convert it.
> > CDbl(var)
> >
> > There is no reason to create a recordset to insert a record into a database.
> > Ray's suggestion to use INSERT INTO, IMO, is the better method. And, a
> > stored procedure is preferred over dynamic SQL, for numerous reasons, speed,
> > modularity, security, etc.
> >
> > If you reply after posts, instead of on top of them, nobody has to read
> > every part of the thread to follow along with the conversation.
> >
> > --
> > Roland Hall
> > /* This information is distributed in the hope that it will be useful, but
> > without any warranty; without even the implied warranty of merchantability
> > or fitness for a particular purpose. */
> > Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
> > WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
> > MSDN Library - http://msdn.microsoft.com/library/default.asp
> >
> >
> >
> Roland,
>
> Will try to remember to reply "under". I tried the typename function to
> check the data type. Everything is showing as IReadCookie type. I tried this
> on both numeric as well as text. Is this a standard cookie type of data that
> I need to convert? That will be my next step. I'm writing the insert
> statement right now so I don't have to use a record set. Thanks for all the
> help!
>
> Gail
>
I've been playing around and it looks like my version of VBScript may not
recognize the currency conversion. I was able to convert the cookie data into
a double after moving it into a variable. Didn't try the conversion directly.
When I used the CCur, I got a type mismatch 'CCur' error. But the CDbl went
through. Guess I need to wait until next month when my new server is
installed to try the CCur again. Thanks for all your help. I've got a bunch
of ideas to try until then.
Gail
Re: Type mismatch error between SQL Money format and Web Cookie va
am 08.03.2006 01:25:38 von Roland Hall
: "GLKGail" wrote:
: > "Roland Hall" wrote:
: > > "GLKGail" wrote in message
: > > news:2824DAF5-4208-45A8-84E8-8D3DA51A8156@microsoft.com...
: > > : Yes, I did a response.write to the next page. "0.15" was displayed.
I'm
: > > using
: > > : Front Page 2002 to design and I initially had the field validated as
: > > numeric.
: > > : Data entry did not trigger an error message. When I check data using
: > > : IsNumeric, it fails, even though the data is visually numeric. It's
as if
: > > the
: > > : cookie is causing it to read as text only.
: > > :
: > > If you want to know what a variable type is, use: Response.Write
: > > typename(var)
: > > IsNumeric is not a very good test.
: > >
: > > You may be testing a string against a double. You can always convert
it.
: > > CDbl(var)
: > >
: > > There is no reason to create a recordset to insert a record into a
database.
: > > Ray's suggestion to use INSERT INTO, IMO, is the better method. And,
a
: > > stored procedure is preferred over dynamic SQL, for numerous reasons,
speed,
: > > modularity, security, etc.
: > >
: > > If you reply after posts, instead of on top of them, nobody has to
read
: > > every part of the thread to follow along with the conversation.
: > Everything is showing as IReadCookie type. I tried this
: > on both numeric as well as text. Is this a standard cookie type of data
that
: > I need to convert? That will be my next step. I'm writing the insert
: > statement right now so I don't have to use a record set. Thanks for all
the
: > help!
I didn't realize IReadCookie would be set instead of a string.
: I've been playing around and it looks like my version of VBScript may not
: recognize the currency conversion. I was able to convert the cookie data
into
: a double after moving it into a variable.
That's what I would normally do. I would assign it to a variable, cleanse
input, and then convert it to the type I wanted. I use CDbl. I have never
used CCur. If I need to show currency, I usually use FormatCurrency only
when displaying.
: Didn't try the conversion directly.
: When I used the CCur, I got a type mismatch 'CCur' error. But the CDbl
went
: through. Guess I need to wait until next month when my new server is
: installed to try the CCur again. Thanks for all your help. I've got a
bunch
: of ideas to try until then.
You can upgrade your scripting engine:
http://msdn.microsoft.com/library/default.asp?url=/downloads /list/webdev.asp
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp