Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: An easy one from a newbie.....


Message #1 by "Rob Clemson" <robclemson@h...> on Fri, 20 Jul 2001 13:11:51
I have the code......



' Update Shopping Cart Quantities

IF Request( "updateQ" ) <> "" THEN

SET RS = Server.CreateObject( "ADODB.Recordset" )

RS.ActiveConnection = Con

sqlString = "SELECT cart_id, cart_quantity FROM cart WHERE cart_userID=" & 

userID

RS.Open sqlString

WHILE NOT RS.EOF

newQ = TRIM( Request( "pq" & RS( "cart_id" ) ) )

IF newQ = "" OR newQ = "0" THEN

  RS.Delete

ELSE

  RS( "cart_quantity" ) = newQ

END IF

  RS.MoveNext

WEND

RS.Close

SET RS = Nothing

END IF



On execution IE5 returns the error Object or provider is not capable of 

performing requested operation.

/addCart.asp, line 42

 Line 42 is.....

RS( "cart_quantity" ) = newQ



Any help much appreciated.



Cheers.



RC.

Message #2 by "Grant I" <giswim1@a...> on Fri, 20 Jul 2001 14:40:34
I think you need to specify some recordset options.  I'm not positive, but 

I believe that, by default, when no RS options are set, it is set to 

adOpenReadOnly (thus not allowing you to edit it).  So you need to 

override this default.  I don't know if you did alredy but you also need 

to #include the file adovbs.inc.  Your code should look like this:



>----Begin sample code----<



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

' Update Shopping Cart Quantities

IF Request( "updateQ" ) <> "" THEN

   SET RS = Server.CreateObject( "ADODB.Recordset" )

   RS.ActiveConnection = Con

   RS.CursorType = adOpenKeyset

   RS.LockType = adLockOptimistic

   sqlString = "SELECT cart_id, cart_quantity FROM cart WHERE

                                       cart_userID=" & userID

   RS.Open sqlString

   WHILE NOT RS.EOF

      newQ = TRIM( Request( "pq" & RS( "cart_id" ) ) )

      IF newQ = "" OR newQ = "0" THEN

        RS.Delete

      ELSE

        RS( "cart_quantity" ) = newQ

      END IF

     RS.MoveNext

   WEND

   RS.Close

   SET RS = Nothing

   END IF



>-----End sample code------<



Notice the two lines I added, setting the lock type and cursor type.  I 

think that should solve your problem.  If not, you may also want to check 

out your db and see if the Cart_Quantity field is set to be an 

integer/number or a text field.  If it is set to be integer/number, change 

the line

      RS( "cart_quantity" ) = newQ

to

      RS( "cart_quantity" ) = cint(newQ)



Hope this helps!!



Grant





> I have the code......

> 

> ' Update Shopping Cart Quantities

> IF Request( "updateQ" ) <> "" THEN

> SET RS = Server.CreateObject( "ADODB.Recordset" )

> RS.ActiveConnection = Con

> sqlString = "SELECT cart_id, cart_quantity FROM cart WHERE cart_userID=" 

& 

> userID

> RS.Open sqlString

> WHILE NOT RS.EOF

> newQ = TRIM( Request( "pq" & RS( "cart_id" ) ) )

> IF newQ = "" OR newQ = "0" THEN

>   RS.Delete

> ELSE

>   RS( "cart_quantity" ) = newQ

> END IF

>   RS.MoveNext

> WEND

> RS.Close

> SET RS = Nothing

> END IF

> 

> On execution IE5 returns the error Object or provider is not capable of 

> performing requested operation.

> /addCart.asp, line 42

>  Line 42 is.....

> RS( "cart_quantity" ) = newQ

> 

> Any help much appreciated.

> 

> Cheers.

> 

> RC.


  Return to Index