Fejl: ASP 0185 (0x80020003)
Hej AlleJeg har tilpasset en kode fra en bog fra IDG.
Det er en indkøbskurv der fungerer med en XML side
Jeg har testet XML delen og den fungerer.
Mit problem opstår når jeg skal omdanne den rå XML.
Jeg får følgende fejl:
Fejltype:
Response-objekt, ASP 0185 (0x80020003)
En standardegenskab for objektet blev ikke fundet.
/Bag.Asp
Her er min kode:
<% Response.Buffer = True %>
<html>
<head>
<title>Implementering af indkøbskurv</title>
</head>
<body bgcolor="#ffffff">
<%
' get or create the bag
Set BagItems = LoadXMLBag()
'Tilføj eller tilpas produkter
if Request.ServerVariables("CONTENT_LENGHT")>0 Then
Select case Tirm(Request.Form("DO"))
Case "Shop for more"
Response.redirect "Test1.Asp"
Response.End
Case "Recalculate"
RecalcBag BagItems
case "Check out"
end select
else
Msg = Trim(request.queryString("Test"))
AddtlProduct Msg, BagItems
end if
Session("BagItems") = BagItems.XML
If BagItems.hasChildNodes Then
PrintBag BagItems
else
Response.write "TEST"
end if
%>
</Body>
</Html>
<SCRIPT LANGUAGE=VBSCRIPT RUNAT=SERVER>
Function LoadXMLBag()
Set XMLDoc = Server.CreateObject("Microsoft.XMLDOM")
If Not IsEmpty(Session("BagItems")) Then
XMLDoc.loadXML CStr(Session("BagItems"))
Set BagItems = XMLDoc.documentElement
Else
Set BagItems = XMLDoc.createElement("BagItems")
Set XMLDoc.documentElement = BagItems
End If
Set LoadXMLBag = BagItems
End Function
Sub AddtlProduct(Msg, BagItems)
bValid = True
if "" = Msg or not IsNumeric(Msg)then
bValid = false
else
set cnn = server.CreateObject("Adodb.connection")
Cnn.ConnectionString = Application("Connectionstring")
Cnn.Open
strRS = "SELECT tblProdukter.produktID, tblProdukter.Navn, tblProdukter.Beskrivelse, tblProdukter.Pris FROM tblProdukter WHERE produktID =" & Msg
set rs = Server.CreateObject("ADODB.Recordset")
set rs = Cnn.Execute(strRS)
if rs.EOF and rs.BOF then
bValid = false
else
avarProduct = rs.GetRows()
end if
rs.close
set rs = Nothing
Cnn.close
set cnn = nothing
end if
'Hvis varen findes, tilføjes den til indkøbskurven
if bValid then
AddProductToBag avarProduct, BagItems
End If
End Sub
Sub AddProductToBag(avarProduct, BagItems)
Set XMLDoc = BagItems.ownerDocument
Set nodeFind = BagItems.selectNodes("product[@produktID=""" & Msg & """]")
If Not nodeFind.length > 0 Then
Set product = XMLDoc.createElement("product")
Set attr = XMLDoc.createAttribute("produktID")
attr.Text = avarProduct(0,0)
product.attributes.setNamedItem(attr)
Set attr = XMLDoc.createAttribute("Navn")
attr.Text = Server.HtmlEncode(avarProduct(1,0))
product.attributes.setNamedItem(attr)
Set attr = XMLDoc.createAttribute("Beskrivelse")
attr.Text = Server.HtmlEncode(avarProduct(2,0))
product.attributes.setNamedItem(attr)
Set attr = XMLDoc.createAttribute("Pris")
attr.Text = avarProduct(3,0)
product.attributes.setNamedItem(attr)
product.text = "1"
BagItems.appendChild(product)
End If
End Sub
Sub PrintBag(BagItems)
Response.write "<FORM METHOD=""POST"" ACTION="""
Response.write Request.ServerVariables("SCRIPT_NAME") & """>"
Response.write "<TABLE><TR><TH>Units</TH>"
Response.write "<TH COLSPAN=2>Product</TH><TH>Unit Price</TH><TH>Price</TH>"
Response.write "</TR>" & vbCrLf
For Each item In BagItems.childNodes
Response.write "<TR>"
Response.write "<TD><input type=""TEXT"" name=""Qty"
Response.write item.attributes.getNamedItem("produktID")
Response.write """ VALUE=""" & item.text & """ SIZE=""3"">"
Response.write "<TD>" & item.attributes.getNamedItem("Navn") & "</TD>"
Response.write "<TD>" & item.attributes.getNamedItem("Beskrivelse") & "</TD>"
nUnitPrice = item.attributes.getNamedItem("Pris")
nSubTotal = item.text * nUnitPrice
nTotal = nTotal + nSubTotal
Response.write "<TD>" & FormatCurrency(nUnitPrice) & "</TD>"
Response.write "<TD><B>" & FormatCurrency(nSubTotal) & "</B></TD>"
Response.write "</TR>" & vbCRLF
Next
Response.write "<TR><TD COLSPAN=5><HR></TD></TR>"
Response.write "<TR><TD COLSPAN=3></TD><TD><B>Total:</B></TD>"
Response.write "<TD><B>" & FormatCurrency(nTotal) & "</B></TD></TR>" & vbCrLf
Response.write "<TR><TD COLSPAN=5 ALIGN=""RIGHT"">"
Response.write "<INPUT TYPE=SUBMIT NAME=""DO"" VALUE=""Shop for more""> "
Response.write "<INPUT TYPE=SUBMIT NAME=""DO"" VALUE=""Recalculate""> "
Response.write "<INPUT TYPE=SUBMIT NAME=""DO"" VALUE=""Check out"">"
Response.write "</TD></TR></TABLE></FORM>"
End Sub
Sub RecalcBag(BagItems)
For each item in BagItems.childNodes
nQty = Trim(request.form("Qty" & item.attributes.getNamedItem("produktID")))
If "" <> nQty And isNummeric(nQty) Then
if nQty < 1 Then
BagItems.removeChild Item
else
item.text = nQty
end if
end if
next
End Sub
</SCRIPT>
Håber nogen kan hjælpe
Hilsen JBjerre