It's not an "error". MySQL Cast will do the 'rounding' for you.
The acutal case is that the 64-bit integer floating value is not affected by
the CAST.
See the manual page for CAST:
http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html
If you would prefer to do the rounding in ASP, push the result into a temporary
variable, then do a CDbl on the variable. Yes, it's a slightly extra step, but
it will ensure that your data stays in the correct format.
J.R.
----------------------------------------
From: Critters <[EMAIL PROTECTED]>
Sent: Tuesday, June 19, 2007 8:37 AM
To: [EMAIL PROTECTED]
Subject: Re: Type Mismatch
Thanks for responding.
If I just response.write score I get 6.5714
I got it working by doing this: cast(sum_score/sum_votes as signed) AS
'score'
Which returns 7. So it is a MySQL error? I would prefer to do the
rounding in ASP and not have to update other scripts giving the same
problems.
--
Dave
J.R. Bullington wrote:
> This is an ASP error, not a MySQL error.
>
> However, try doing a
>
> response.write rs("Score")
> response.flush
>
> Then you will see why you are getting the mismatch error. It is probably the
> fact that rs("Score") is not returning an integer or number of any kind (i.e.
> if rs("score") is null).
>
> HTH!
>
> ----------------------------------------
> From: Critters
> Sent: Tuesday, June 19, 2007 7:44 AM
> To: MySQL General
> Subject: Type Mismatch
>
> Hi,
> I hope someone can help me with my problem, something that has come up
> when moving code and DB to a new server:
>
> Connection:
> driver={MySQL ODBC 3.51
> DRIVER};server=localhost;uid=xxxxxxxxxx;pwd=xxxxxxxxxx;database=xxxxxxxxxx;option=16387
>
> SQL:
> SELECT (sum_score/sum_votes) AS 'score' FROM xxxxxxxxxx WHERE id =
> xxxxxxxxxx
>
> Value of "score":
> 6.2153
>
> ASP:
> <%=int(RS("score")*25)-20%>
>
> Error:
> Microsoft VBScript runtime (0x800A000D)
> Type mismatch
>
> Any help appreciated, I did not have this problem when I had the same
> set-up but on a server running an earlier version of MySQL and the ODBC
> driver.
> --
> David Scott
>
>