Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Type Mismatch using CLng and CInt

1,466 views
Skip to first unread message

ashl...@my-deja.com

unread,
Jul 10, 2000, 3:00:00 AM7/10/00
to
Hi,
I'm trying to use vbscript to populate a session
variable. I am using Visual Interdev and taking
a value from a textbox, for the purpose of a
database query this must be numeric. I have
jscript code to validate input on the client to
make sure it is numeric and as far as I'm
concerned the value is numeric but the database
query fails because it is populating the session
variable with a string. I have tried to use the
following code to force the var to take a numeric
type: -

Session("customer_number") = CLng
(txtCustomerNumber.value)

(I have also tried CInt)

I get the following error: -

Microsoft VBScript runtime error '800a000d'

Type mismatch 'CLng'

/customer_search.asp, line 88

I have hardcoded a numeric value into the session
variable and the database query works just
fine. I have also put the value from the textbox
into an alert box with question marks either side
to check for hidden characters (there were none).

I am really starting to lose it with this, has
anyone got any ideas on this problem or any
suggestions on how to populate a session var from
jscript plz let me know.
TIA,
Ashley.


Sent via Deja.com http://www.deja.com/
Before you buy.

ashl...@my-deja.com

unread,
Jul 10, 2000, 3:00:00 AM7/10/00
to
Hi,
I'm having a problem with a type mismatch when using CLng and CInt.
I'm taking a value from a textbox in IE4 populating a session var with
it (This has JScript validation on the client to check it is numeric)
and trying to use it as part of a database query, the database query is
failing because it says the value is not numeric (If I hard code a
numeric value into the session var the database query works fine). The
contents of the textbox are numeric as the validation checks this (as a
seperate test I put dashes either side of the contents and output that
in an alert box to check for hidden chars of which there were none). I
have tried to force the var to type int or lng using CInt and Clng as
follows: -

Session("customer_number") = CLng(txtCustomerNumber.value)

I get the following error returned to the browser: -

Microsoft VBScript runtime error '800a000d'

Type mismatch 'CLng'

customer search.asp, line 88

Anyone got any ideas on where I'm going wrong? Or any ideas how I
could populate the session var using JSCript?
TIA,
Ashley

Heather Haindel

unread,
Jul 10, 2000, 3:00:00 AM7/10/00
to
Try writing out the value of txtCustomerNumber.value. Then try writing
that value plus one. If it will calculate, your value is numeric. If
not, your value is text.
In article <8kc750$bj2$1...@nnrp1.deja.com>,

ashl...@my-deja.com wrote:
> Hi,
> I'm having a problem with a type mismatch when using CLng and CInt.

> Session("customer_number") = CLng(txtCustomerNumber.value)


jer...@mcsgroup.com

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Ashley, I've got a couple of thoughts but I'd forget about converting your
variable to a numeric type until you're ready to use it. You say that you
are already verifying by jscript that the user is typing in a numeric
value so just set your session variable to the input value and when ready
to use in a query instead of using just the session variable use the
converted session variable, for example:

use CLng(Session("customer_number")) as input to your query.

Also, when setting your session variable make sure the code is on one line
or use a continuation character. I can't tell from your example if that
was actual code or you split it into two lines to fit this post. For
example the code should be:

Session("customer_number") = CLng(txtCustomerNumber.value)

OR
Session("customer_number") = CLng _
(txtCustomerNumber.value)

I recommend the first.

One last thing, I've been working with VBScript and with VB but I haven't
mixed the two. What I mean to say that on a VB form I have text boxes but
in an ASP web page I have Form <input> fields of type=text so when I want
to assign the value of what was typed in I would have:
to put the field on the page (in plain html):
<form>
<input type=text name=customer_number_input>
</form>

to assign it to a session variable in vbscript:
<%
Session("customer_number") = Request.Form("customer_number_input")
%>

to use it when calling a Query routine that needs a number value

Dim CustRecordset

Set CustRecordset = GetMasterByCustNum( CLng( Session("customer_number") )
)

Hope some of this helps.

Jerry Russell
jer...@mcsgroup.com

====================================================================================


Hi,
I'm trying to use vbscript to populate a session
variable. I am using Visual Interdev and taking
a value from a textbox, for the purpose of a
database query this must be numeric. I have
jscript code to validate input on the client to
make sure it is numeric and as far as I'm
concerned the value is numeric but the database
query fails because it is populating the session
variable with a string. I have tried to use the
following code to force the var to take a numeric
type: -

Session("customer_number") = CLng
(txtCustomerNumber.value)

(I have also tried CInt)

I get the following error: -

Microsoft VBScript runtime error '800a000d'

Type mismatch 'CLng'

/customer_search.asp, line 88

I have hardcoded a numeric value into the session
variable and the database query works just
fine. I have also put the value from the textbox
into an alert box with question marks either side
to check for hidden characters (there were none).

I am really starting to lose it with this, has
anyone got any ideas on this problem or any
suggestions on how to populate a session var from
jscript plz let me know.
TIA,
Ashley.

Sarah Cavanagh

unread,
Jul 26, 2000, 3:00:00 AM7/26/00
to

Ashley
I think that you are referencing the textbox incorrectly. You need
to get at it through the request object. Try
"Request.form("txtcustomerNumber")".
Good luck,
Brian Chandley
0 new messages