Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Eagle_f90
Constraint Violating Yak Guru
424 Posts |
Posted - 2004-09-03 : 21:59:32
|
I ahve ascript that opens a SQL 2k table and addes new records to it, but when I run it I get this error:quote: Microsoft OLE DB Provider for ODBC Drivers error '80040e21'Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done./cgi-bin/password/test3/manage/buyshop.asp, line 32
This is the code I am using:<%@language=vbscript%><%option explicit%><!--#include virtual="/adovbs.inc"--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>You bought an item for your merch shop</title><link rel="stylesheet" type="text/css" href="http://www.eagledbzrpg.com/style.css" /></head><body><%dim item, therethere = "no"item = request.form("item")objrs.open "Gotenshop", objconn, , adlockoptimistic, adcmdtabledo while not objrs.eofif objrs("item") = item thenobjrs("qty") = objrs("qty") + 1objrs.updatethere = "yes"end ifobjrs.movnextloopif there = "no" thenobjrs.addnewobjrs("item") = item 'This is line 32objrs("qty") = 1objrs("price") = -1objrs.updateend ifobjrs.close%><br /><a href="../index.asp">Back to your member's only page</a></body></html> Can anyone see what is wrong?--For those with wings, fly to your dreamsDearms are what are found at the end of reality, and your reality if what is found at the end of your dreams. |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-09-04 : 09:05:49
|
?????You have an item. You open a recordset on the table and loop through each record searching for that item?Are you really sur ethis is what you want to do? Think what woulod happen if there were a million recs in that table in the future.objrs.addnew and anything that retrieves a whole table is to be avoided.Check what is in item and the datatype of the column in the database.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
Eagle_f90
Constraint Violating Yak Guru
424 Posts |
Posted - 2004-09-05 : 10:39:51
|
quote: Originally posted by nr ?????You have an item. You open a recordset on the table and loop through each record searching for that item?Are you really sur ethis is what you want to do? Think what woulod happen if there were a million recs in that table in the future.objrs.addnew and anything that retrieves a whole table is to be avoided.Check what is in item and the datatype of the column in the database.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.
I don't understand what your getting at. Are you saiying because I am looping though the records and then later trying to add a new one I am gettin this error? Or are you just saying I don't know how to make a table and should redesigin the hole dame thing (I know I don't know how to do it and I don't have time to redesign the hold dame thing).--For those with wings, fly to your dreamsDearms are what are found at the end of reality, and your reality if what is found at the end of your dreams. |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2004-09-05 : 12:46:21
|
Shot in the dark from the hip...Maybe adcmdtable doesn't make the rs updateable ( since there is no updatecommand specified for the rs )Check if objrs.Supports(adUpdate) returns true ?.nr suggests that you just issue some sql like the following to the database:if exists( select * from theTable where item = "youritem" ) update theTable set qty = qty + 1 where item = "youritem"else insert theTable(item,qty,price) values("yoritem",1,-1)And you don't retrieve an recordset at all.That would be tons and tons more efficient rockmoose/* Chaos is the nature of things...Order is a lesser state of chaos */ |
|
|
|
|
|
|
|