Groups | Blog | Home
all groups > inetserver asp general > july 2004 >

inetserver asp general : type mismatch



shank
7/27/2004 6:24:33 PM
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Ð
7/28/2004 3:41:53 AM
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


[quoted text, click to view]
Agoston Bejo
7/28/2004 9:40:43 AM
Hi,


[quoted text, click to view]

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.


[quoted text, click to view]

AddThis Social Bookmark Button