Type mismatch problems with select box list

Discussion in 'ASP General' started by .Net Sports, Dec 21, 2009.

  1. .Net Sports

    .Net Sports Guest

    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
    .Net Sports, Dec 21, 2009
    #1
    1. Advertising

  2. .Net Sports

    Bob Barrows Guest

    ..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
    Bob Barrows, Dec 21, 2009
    #2
    1. Advertising

  3. .Net Sports

    Evertjan. Guest

    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)
    Evertjan., Dec 21, 2009
    #3
  4. .Net Sports

    Bob Barrows Guest

    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"
    Bob Barrows, Dec 21, 2009
    #4
  5. .Net Sports

    .Net Sports Guest

    On Dec 21, 3:14 pm, "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>

    >
    > >> 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>
    .Net Sports, Dec 22, 2009
    #5
  6. .Net Sports

    Bob Barrows Guest

    ..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"
    Bob Barrows, Dec 22, 2009
    #6
  7. Gazing into my crystal ball I observed ".Net Sports"
    <> writing in news:690cd66f-a649-4ec6-ba82-
    :

    > 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
    Adrienne Boswell, Dec 22, 2009
    #7
  8. .Net Sports

    Dan Guest

    ".Net Sports" <> wrote in message
    news:...
    > 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
    Dan, Dec 22, 2009
    #8
  9. .Net Sports

    Evertjan. Guest

    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)
    Evertjan., Dec 22, 2009
    #9
  10. .Net Sports

    Bob Barrows Guest

    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
    Bob Barrows, Dec 22, 2009
    #10
  11. .Net Sports

    .Net Sports Guest

    On Dec 21, 7:33 pm, Adrienne Boswell <> wrote:
    > Gazing into my crystal ball I observed ".Net Sports"
    > <> writing in news:690cd66f-a649-4ec6-ba82-
    > :
    >
    > > 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 Serviceshttp://www.cavalcade-of-coding.info
    > Please respond to the group so others can share



    Thanks! the main culprit was not having the current value for the
    record in the value tag: <option value="& RSFORM("level")&"
    SELECTED>"............
    .Net Sports, Dec 22, 2009
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gnarlodious
    Replies:
    4
    Views:
    17,587
    elizas
    May 5, 2010
  2. Steve
    Replies:
    16
    Views:
    320
    Steven Burn
    May 30, 2006
  3. select query data type mismatch

    , Jul 1, 2008, in forum: ASP General
    Replies:
    3
    Views:
    310
    Daniel Crichton
    Jul 2, 2008
  4. palmiere
    Replies:
    1
    Views:
    397
    Erwin Moller
    Feb 9, 2004
  5. programmingzeal
    Replies:
    0
    Views:
    1,115
    programmingzeal
    May 6, 2012
Loading...

Share This Page