Re: Query-based update failed because the row to update could not be found
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Mon, 11 Apr 2005 11:36:30 -0400
Why are you still opening a recordset? With pessimistic locking?? Avoid
pessimistic locking in ASP applications.
You did not read my code example carefully enough. (or you decided I had
done something wrong ... )
See below for the corrections:
Craig wrote:
> Here's the current code. Error is happening on the cmd.Execute line:
>
>
> Dim Conn, connection, rsProd
>
> set Conn = Server.CreateObject("ADODB.Connection")
> Conn.CursorLocation = adUseServer
>
> connection =
>
"driver={MySQL};server=sqlc2.megasqlservers.com;database=products_premieres_
> ca;uid=dbm.premieres.ca;pwd=roger;option=32"
> Conn.open (connection)
>
eliminate these lines (no recordset is needed):
*************************************************************
> set rsProd = Server.CreateObject("ADODB.Recordset")
> rsProd.CursorLocation = adUseServer
>
> rsProd.Open "SELECT tallyitems, orderID, productID, quantity FROM
> itemsOrdered WHERE orderID="& intOrderID, _
> Conn, adOpenDynamic, adLockPessimistic, adCmdText
>
************************************************************
> Dim cmd, sSQL, arParms
>
> if intQuant <> "" then
Again, a slight improvement:
intQuant = CInt(intQuant)
> if intQuant = 0 then
> sSQL = "DELETE FROM itemsOrdered " & _
> "WHERE orderID = " & intOrderID
This should read:
"WHERE orderID = ?"
> arParms = Array(intOrderID)
> else
> sSQL = "UPDATE itemsOrdered SET quantity = intQuant "
> & _ "WHERE orderID = " & intOrderID
This should read:
sSQL = "UPDATE itemsOrdered SET quantity = ?"
& _ "WHERE orderID = ?"
The question marks are called "parameter placeholders". The values in the
arParms array will be substituted for the placeholders when the command is
executed.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
.
- Follow-Ups:
- References:
- Query-based update failed because the row to update could not be found
- From: Craig
- Re: Query-based update failed because the row to update could not be found
- From: Bob Barrows [MVP]
- Re: Query-based update failed because the row to update could not be found
- From: Craig
- Re: Query-based update failed because the row to update could not be found
- From: Bob Barrows [MVP]
- Re: Query-based update failed because the row to update could not be found
- From: Craig
- Re: Query-based update failed because the row to update could not be found
- From: Bob Barrows [MVP]
- Re: Query-based update failed because the row to update could not be found
- From: Craig
- Query-based update failed because the row to update could not be found
- Prev by Date: Re: ASP + SQL Makes Page Load Really Slow
- Next by Date: Re: Query-based update failed because the row to update could not be found
- Previous by thread: Re: Query-based update failed because the row to update could not be found
- Next by thread: Re: Query-based update failed because the row to update could not be found
- Index(es):
Relevant Pages
|
|