Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Type mismatch problems with select box list

Reply
Thread Tools

Type mismatch problems with select box list

 
 
.Net Sports
Guest
Posts: n/a
 
      12-21-2009
I have an item that goes into sql database coming from a select
pulldown list.:

<br>ACCESS LEVEL:<br> <select name=level><option value= SELECTED>"&
RSFORM("level")&"</option><option value=1>1</option><option value=2>2</
option></select>

Level is an integer datatype in the dbase, and is either a numeral 1,
2 ,or 3

when trying to either update or insert into the dbase:

RSEVENTS("level") = cint(request("level"))

I get a vbscript Type mismatch: 'cint' on this line; get the same
error no matter if i leave the function blank " request("level")

??
NS

 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      12-21-2009
..Net Sports wrote:
> I have an item that goes into sql database coming from a select
> pulldown list.:
>
> <br>ACCESS LEVEL:<br> <select name=level><option value= SELECTED>"&
> RSFORM("level")&"</option><option value=1>1</option><option
> value=2>2</ option></select>
>
> Level is an integer datatype in the dbase, and is either a numeral 1,
> 2 ,or 3
>
> when trying to either update or insert into the dbase:
>
> RSEVENTS("level") = cint(request("level"))
>
> I get a vbscript Type mismatch: 'cint' on this line; get the same
> error no matter if i leave the function blank " request("level")
>
> ??
> NS

Show us the result of

Response.Write request("level")
--
HTH,
Bob Barrows


 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      12-21-2009
Bob Barrows wrote on 21 dec 2009 in
microsoft.public.inetserver.asp.general:

> .Net Sports wrote:
>> I have an item that goes into sql database coming from a select
>> pulldown list.:
>>
>> <br>ACCESS LEVEL:<br> <select name=level><option value= SELECTED>"&
>> RSFORM("level")&"</option><option value=1>1</option><option
>> value=2>2</ option></select>
>>
>> Level is an integer datatype in the dbase, and is either a numeral 1,
>> 2 ,or 3
>>
>> when trying to either update or insert into the dbase:
>>
>> RSEVENTS("level") = cint(request("level"))
>>
>> I get a vbscript Type mismatch: 'cint' on this line; get the same
>> error no matter if i leave the function blank " request("level")


What is "leaving the function blank?
What is "blank", an empty string?

Do you mean the argument of cint() ?

Cint() errors out if the argument is not convertable to a number,
so an empty string will give an error.


>> ??
>> NS

> Show us the result of
>
> Response.Write request("level")


This will possibly not help you, Bob,
as you cannot see the difference between
"1" and +1.

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

and never never use request("level")

specify what type of request you want to read, like:

request.cookies("level")

request.form("level")

request.querystring("level")

Request.servervariables("..")

or other.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      12-21-2009
Evertjan. wrote:
> Bob Barrows wrote on 21 dec 2009 in
> microsoft.public.inetserver.asp.general:
>
>> .Net Sports wrote:
>>> I have an item that goes into sql database coming from a select
>>> pulldown list.:
>>>
>>> <br>ACCESS LEVEL:<br> <select name=level><option value= SELECTED>"&
>>> RSFORM("level")&"</option><option value=1>1</option><option
>>> value=2>2</ option></select>

>> Show us the result of
>>
>> Response.Write request("level")

>
> This will possibly not help you, Bob,
> as you cannot see the difference between
> "1" and +1.
>


Are you sure? Did you look at his source?



--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
.Net Sports
Guest
Posts: n/a
 
      12-22-2009
On Dec 21, 3:14*pm, "Evertjan." <(E-Mail Removed)> wrote:
> Bob Barrows wrote on 21 dec 2009 in
> microsoft.public.inetserver.asp.general:
>
>
>
> > .Net Sports wrote:
> >> I have an item that goes into sql database coming from a select
> >> pulldown list.:

>
> >> <br>ACCESS LEVEL:<br> <select name=level><option value= SELECTED>"&
> >> RSFORM("level")&"</option><option value=1>1</option><option
> >> value=2>2</ option></select>

>
> >> Level is an integer datatype in the dbase, and is either a numeral 1,
> >> 2 ,or 3

>
> >> when trying to either update or insert into the dbase:

>
> >> RSEVENTS("level") = cint(request("level"))

>
> >> *I get a vbscript Type mismatch: 'cint' *on this line; get the same
> >> error no matter if i leave the function blank " request("level")

>
> What is "leaving the function blank?
> What is "blank", an empty string?
>
> Do you mean the argument of cint() ?
>
> Cint() errors out if the argument is not convertable to a number,
> so an empty string will give an error.
>
> >> ??
> >> NS

> > Show us the result of

>
> > Response.Write request("level")

>
> This will possibly not help you, Bob,
> as you cannot see the difference between
> "1" and +1.
>
> ====================
>
> and never never use request("level")
>
> specify what type of request you want to read, like:
>
> request.cookies("level")
>
> request.form("level")
>
> request.querystring("level")
>
> Request.servervariables("..")
>
> or other.
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)


If i don't need to change the Level when editing the record, then i
want to leave what their existing level number is in the first line of
the select option box: <select name=level><option value= SELECTED>"&
RSFORM("level")&"</option><option value=1>1</option><option
value=2>2</
option></select>

I tried response.writing the request("level") on the next page, and it
is blank , so something is not coming across in the post right:

<form action="resources-edit-post.asp?qencl=admin" name="frmUser"
Method="Post">
''' content
</form>
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      12-22-2009
..Net Sports wrote:
>
> If i don't need to change the Level when editing the record, then i
> want to leave what their existing level number is in the first line of
> the select option box: <select name=level><option value= SELECTED>"&
> RSFORM("level")&"</option><option value=1>1</option><option
> value=2>2</
> option></select>
>
> I tried response.writing the request("level") on the next page, and it
> is blank , so something is not coming across in the post right:
>



Look at the value attributes of each of your option elements ... which one
is selected when you submit the form? What is the value of that selected
option?


--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Adrienne Boswell
Guest
Posts: n/a
 
      12-22-2009
Gazing into my crystal ball I observed ".Net Sports"
<(E-Mail Removed)> writing in news:690cd66f-a649-4ec6-ba82-
http://www.velocityreviews.com/forums/(E-Mail Removed):

> If i don't need to change the Level when editing the record, then i
> want to leave what their existing level number is in the first line of
> the select option box: <select name=level><option value= SELECTED>"&
> RSFORM("level")&"</option><option value=1>1</option><option
> value=2>2</
> option></select>
>
> I tried response.writing the request("level") on the next page, and it
> is blank , so something is not coming across in the post right:
>
><form action="resources-edit-post.asp?qencl=admin" name="frmUser"
> Method="Post">
> ''' content
></form>
>


You've got a few bad things going on here.

1. You really should quote all your HTML attributes. It makes debugging
a lot easier.
2. What is the value of the option? You have a blank value, you really
do, and had you quoted attribute values correctly you would have seen
that. Look at the source of the document when it has been rendered in a
browser and you will see what I mean. This is the correct method:

<option value="<%=rsform("level")%>" selected><%=rsform("level")%>
</option>

3. Are you looping through the records - from your naming conventions it
appears you are, so why would you have ALL options selected? You have
to put some appropriate if statements in there.

4. It's not a good idea to use request("level") - because you are not
explicitly telling the server to look for a post value. You should
always use request.form("field") for post method, or request.querystring
("field") for get method, or request.cookies("field") for cookies, or
request.servervariables("field").

I got into trouble a long time ago, before someone here showed me the
error of my ways, where I had an input that was called url, and when I
did request("url") it was giving me the url of the page, not information
the user had posted in the form. IIRC server variables are read first.

5. Using the name attribute of the form element is deprecated. You
would do better to use the id attribute, especially if you are going to
be using client side scripting for modern browsers.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

 
Reply With Quote
 
Dan
Guest
Posts: n/a
 
      12-22-2009

".Net Sports" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have an item that goes into sql database coming from a select
> pulldown list.:
>
> <br>ACCESS LEVEL:<br> <select name=level><option value= SELECTED>"&
> RSFORM("level")&"</option>


There's your problem, right there, at the value=. Where's the value? For
example, is RSFORM("level") is the value 1, the HTML becomes

<select name=level><option value= SELECTED>1</option>

so if the user picks 1 from the list (which is pre-selected so is highly
likely), the value is blank because you have not provided the value. The
change for this line should be something like

<br>ACCESS LEVEL:<br> <select name=level><option value=" & RSFORM("level") &
" SELECTED>" & RSFORM("level") & "</option>


--
Dan


 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      12-22-2009
Bob Barrows wrote on 22 dec 2009 in
microsoft.public.inetserver.asp.general:

> Evertjan. wrote:
>> Bob Barrows wrote on 21 dec 2009 in
>> microsoft.public.inetserver.asp.general:
>>
>>> .Net Sports wrote:
>>>> I have an item that goes into sql database coming from a select
>>>> pulldown list.:
>>>>
>>>> <br>ACCESS LEVEL:<br> <select name=level><option value= SELECTED>"&
>>>> RSFORM("level")&"</option><option value=1>1</option><option
>>>> value=2>2</ option></select>
>>> Show us the result of
>>>
>>> Response.Write request("level")

>>
>> This will possibly not help you, Bob,
>> as you cannot see the difference between
>> "1" and +1.
>>

>
> Are you sure? Did you look at his source?


Possibly I was,

.... but not now, as both will be accepted by cint()


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      12-22-2009
Evertjan. wrote:
> Bob Barrows wrote on 22 dec 2009 in
> microsoft.public.inetserver.asp.general:
>
>> Evertjan. wrote:
>>> Bob Barrows wrote on 21 dec 2009 in
>>> microsoft.public.inetserver.asp.general:
>>>
>>>> .Net Sports wrote:
>>>>> I have an item that goes into sql database coming from a select
>>>>> pulldown list.:
>>>>>
>>>>> <br>ACCESS LEVEL:<br> <select name=level><option value=
>>>>> SELECTED>"& RSFORM("level")&"</option><option
>>>>> value=1>1</option><option value=2>2</ option></select>
>>>> Show us the result of
>>>>
>>>> Response.Write request("level")
>>>
>>> This will possibly not help you, Bob,
>>> as you cannot see the difference between
>>> "1" and +1.
>>>

>>
>> Are you sure? Did you look at his source?

>
> Possibly I was,
>
> ... but not now, as both will be accepted by cint()
>
>

I guess you're missing the point. If the form above is submitted with
the default selection,
request("level")
, or, more correctly (as you pointed out):
request.form("level")
, will return an empty string, in which case cint("") will raise a type
mismatch error.

--
HTH,
Bob Barrows


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL Type Mismatch error indexed name returns a value whose type does not match programmingzeal VHDL 0 05-06-2012 06:38 AM
select query data type mismatch eyoung1@uiuc.edu ASP General 3 07-02-2008 03:44 PM
ASP Type mismatch error with SELECT...FOR UPDATE statement Steve ASP General 16 05-30-2006 05:42 PM
populate one list box with selected values from another list box steven.cooper@infocision.com ASP .Net 1 03-12-2005 11:29 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments