type mismatch

Discussion in 'ASP General' started by shank, Jul 27, 2004.

  1. shank

    shank Guest

    What is the proper use for CInt ..?
    I get a type mismatch error whether I use it or not.
    I assumed I needed it because I need to make sure Request("Qty") and
    Request("Weight") were integers.

    Also, does this loop structure appear to be correct. rsCart recordset is
    just above this code.
    thanks

    <%
    If Request("QtyUpdate") <> "" Then
    Do While Not rsCart.EOF

    varNewQty = CInt(Request("Qty")) <-- Type mismatch error

    varNewWeight = varNewQty * CInt((rsCart.Fields.Item("Weight").Value))
    Dim DataConn
    Set DataConn = Server.CreateObject("ADODB.Connection")
    DataConn.Open MM_GenKAccess_STRING
    SQL = "UPDATE Cart SET Cart.Qty = '" & varNewQty & "', Cart.Weight = '" &
    varNewWeight & "' WHERE Cart.OrderNo = '" & varOrderNo & "'"
    DataConn.Execute(SQL)
    Loop
    Response.Redirect("cart.asp")
    End If
    %>
     
    shank, Jul 27, 2004
    #1
    1. Advertising

  2. shank

    Bã§TãRÐ Guest

    Woah - why is your SQL statement in the loop? Everytime you iterate through the loop you run that SQL command - thats a serious performance issue.
    Take all of this info out of the loop for one and see if that works.

    I'm not sure what is happening above this so I dont know why your stuff is in the loop - post a little more so I can see what the page is doing

    - Bastard



    varNewQty = CInt(Request("Qty"))
    varNewWeight = varNewQty * CInt((rsCart.Fields.Item("Weight").Value))

    Dim DataConn
    Set DataConn = Server.CreateObject("ADODB.Connection")
    DataConn.Open MM_GenKAccess_STRING

    SQL = "UPDATE Cart SET
    Cart.Qty = '" & varNewQty & "'
    Cart.Weight ='" & varNewWeight & "'
    WHERE Cart.OrderNo = '" & varOrderNo & "'"

    DataConn.Execute(SQL)


    If Request("QtyUpdate") <> "" Then
    something..............
    Response.Redirect("cart.asp")
    End If


    On Tue, 27 Jul 2004 18:24:33 -0400, "shank" <> wrote:

    >What is the proper use for CInt ..?
    >I get a type mismatch error whether I use it or not.
    >I assumed I needed it because I need to make sure Request("Qty") and
    >Request("Weight") were integers.
    >
    >Also, does this loop structure appear to be correct. rsCart recordset is
    >just above this code.
    >thanks
    >
    ><%
    >If Request("QtyUpdate") <> "" Then
    > Do While Not rsCart.EOF
    >
    > varNewQty = CInt(Request("Qty")) <-- Type mismatch error
    >
    > varNewWeight = varNewQty * CInt((rsCart.Fields.Item("Weight").Value))
    > Dim DataConn
    > Set DataConn = Server.CreateObject("ADODB.Connection")
    > DataConn.Open MM_GenKAccess_STRING
    > SQL = "UPDATE Cart SET Cart.Qty = '" & varNewQty & "', Cart.Weight = '" &
    >varNewWeight & "' WHERE Cart.OrderNo = '" & varOrderNo & "'"
    > DataConn.Execute(SQL)
    > Loop
    > Response.Redirect("cart.asp")
    >End If
    >%>
    >
     
    Bã§TãRÐ, Jul 28, 2004
    #2
    1. Advertising

  3. shank

    Agoston Bejo Guest

    Hi,


    "shank" <> wrote in message
    news:u09k$...
    > What is the proper use for CInt ..?
    > I get a type mismatch error whether I use it or not.
    > I assumed I needed it because I need to make sure Request("Qty") and
    > Request("Weight") were integers.

    [...]
    > varNewQty = CInt(Request("Qty")) <-- Type mismatch error


    Check if Request("Qty") is really a number and most of all if it is not ""
    (empty string). Mostly this error occurs when Request(...) returns an empty
    string because it itsn't passed.


    > varNewWeight = varNewQty * CInt((rsCart.Fields.Item("Weight").Value))
    > Dim DataConn
    > Set DataConn = Server.CreateObject("ADODB.Connection")
    > DataConn.Open MM_GenKAccess_STRING
    > SQL = "UPDATE Cart SET Cart.Qty = '" & varNewQty & "', Cart.Weight = '" &
    > varNewWeight & "' WHERE Cart.OrderNo = '" & varOrderNo & "'"
    > DataConn.Execute(SQL)
    > Loop
    > Response.Redirect("cart.asp")
    > End If
    > %>
    >
    >
     
    Agoston Bejo, Jul 28, 2004
    #3
    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. data type mismatch error

    , Aug 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    643
    Karl Seguin
    Aug 10, 2005
  2. type mismatch error

    , Aug 12, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,389
    Kevin Spencer
    Aug 12, 2005
  3. Artie Gold

    Re: type mismatch

    Artie Gold, Feb 28, 2004, in forum: C Programming
    Replies:
    0
    Views:
    409
    Artie Gold
    Feb 28, 2004
  4. Harry Pehkonen

    win32com, string array --> Type mismatch?

    Harry Pehkonen, Aug 8, 2003, in forum: Python
    Replies:
    2
    Views:
    1,896
    Harry Pehkonen
    Aug 11, 2003
  5. programmingzeal
    Replies:
    0
    Views:
    1,147
    programmingzeal
    May 6, 2012
Loading...

Share This Page