Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Type mismatch Provider error '80020005' - trying to split array of different types


Message #1 by "ANTONIO JONES" <ajjones13@m...> on Mon, 29 Apr 2002 20:59:48
I am trying to add multiple products or records at one time to an Access 
database.  The form uses 4 fields, 3 of which are from a table in an 
access database (prodID, ProdName, Price) and the fourth is just a 
quantity box (intquant).  The form passes a hidden field. Getting this 
error
Provider error '80020005'  
Type mismatch
which points to --> rsAdd("quantity") = itemInfo(2) <-- below 

I think it's bringing all the quatities over, I'm a little stumped HELP!! 

----------------------------------------------------------
Previous page (Form page)
<input type="hidden" name="strAddProducts" value="<%= intProdID %>,<%= 
strProdName %>, <%Request.form("intquant")%> ">

----------------------------------------------------------

<!-- #include file="db.asp" -->
<!-- #include file="adovbs.inc" -->
<%    



    Sub CreateNewOrder()
        Application.lock
        if Application("orderID") = "" then
			Application("orderID") = 1
        end if
       
        
       intOrderID = Application("orderID")
       Session("orderID") = intOrderID
       Conn.Execute("INSERT INTO orders " _
		& " (orderID, status) values " _
		& " ("&intOrderID&", 'OPEN')")
		
		Application("orderID") = Application("orderID") + 1
       Application.Unlock
    End Sub

    Sub AddToOrder(nOrderID, nProductID, strPName, nQuant)
        sqlText = "INSERT INTO itemsOrdered " _
            & " (orderID, productID, pName, quantity) values " _ 
            & " 
("&nOrderID&", "&nProductID&", '"&strPName&"', "&nQuant&")" 
        Conn.Execute(sqlText)

    End Sub
  
    
    'Main program 
    
    set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open ConString

    intOrderID = cstr(Session("orderID"))
    if intOrderID = "" then
       CreateNewOrder
    end if

dim rsAdd
 set rsAdd = Server.CreateObject("ADODB.Recordset")
        rsAdd.Open "itemsOrdered", Conn, adOpenStatic, adLockOptimistic, 
adCmdTable

for each item in Request.form("strAddProducts")

     strAddProducts = cstr(item)
     itemInfo = split(strAddProducts, ",")
     
     
           rsAdd.addNew
           rsAdd("orderID") = intOrderID
           rsAdd("productID") = itemInfo(0)
           rsAdd("pName") = itemInfo(1)
           rsAdd("quantity") = itemInfo(2)
           rsAdd.Update

AddToOrder intOrderID, intProdID, strName, intQuant 
 next

           
Response.Redirect("review.asp")


	Conn.Close
    set Conn = Nothing
%>
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 30 Apr 2002 12:43:40 +1000
How about using Response.Write() to output the values in your array to the
screen so that you can *see* exactly what you are sending to the database?

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "ANTONIO JONES" <ajjones13@m...>
Subject: [access_asp] Type mismatch Provider error '80020005' - trying to
split array of different types


:
: I am trying to add multiple products or records at one time to an Access
: database.  The form uses 4 fields, 3 of which are from a table in an
: access database (prodID, ProdName, Price) and the fourth is just a
: quantity box (intquant).  The form passes a hidden field. Getting this
: error
: Provider error '80020005'
: Type mismatch
: which points to --> rsAdd("quantity") = itemInfo(2) <-- below
:
: I think it's bringing all the quatities over, I'm a little stumped HELP!!
:
: ----------------------------------------------------------
: Previous page (Form page)
: <input type="hidden" name="strAddProducts" value="<%= intProdID %>,<%
: strProdName %>, <%Request.form("intquant")%> ">
:
: ----------------------------------------------------------
:
: <!-- #include file="db.asp" -->
: <!-- #include file="adovbs.inc" -->
: <%
:
:
:
:     Sub CreateNewOrder()
:         Application.lock
:         if Application("orderID") = "" then
: Application("orderID") = 1
:         end if
:
:
:        intOrderID = Application("orderID")
:        Session("orderID") = intOrderID
:        Conn.Execute("INSERT INTO orders " _
: & " (orderID, status) values " _
: & " ("&intOrderID&", 'OPEN')")
:
: Application("orderID") = Application("orderID") + 1
:        Application.Unlock
:     End Sub
:
:     Sub AddToOrder(nOrderID, nProductID, strPName, nQuant)
:         sqlText = "INSERT INTO itemsOrdered " _
:             & " (orderID, productID, pName, quantity) values " _
:             & "
: ("&nOrderID&", "&nProductID&", '"&strPName&"', "&nQuant&")"
:         Conn.Execute(sqlText)
:
:     End Sub
:
:
:     'Main program
:
:     set Conn = Server.CreateObject("ADODB.Connection")
:     Conn.Open ConString
:
:     intOrderID = cstr(Session("orderID"))
:     if intOrderID = "" then
:        CreateNewOrder
:     end if
:
: dim rsAdd
:  set rsAdd = Server.CreateObject("ADODB.Recordset")
:         rsAdd.Open "itemsOrdered", Conn, adOpenStatic, adLockOptimistic,
: adCmdTable
:
: for each item in Request.form("strAddProducts")
:
:      strAddProducts = cstr(item)
:      itemInfo = split(strAddProducts, ",")
:
:
:            rsAdd.addNew
:            rsAdd("orderID") = intOrderID
:            rsAdd("productID") = itemInfo(0)
:            rsAdd("pName") = itemInfo(1)
:            rsAdd("quantity") = itemInfo(2)
:            rsAdd.Update
:
: AddToOrder intOrderID, intProdID, strName, intQuant
:  next
:
:
: Response.Redirect("review.asp")
:
:
: Conn.Close
:     set Conn = Nothing
: %>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index