Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Record Saved Twice


Message #1 by "Enzo Zaragoza" <enzaux@g...> on Thu, 25 Oct 2001 04:01:32 +0800
I was wondering why is it that everytime I add a new record for Carts it is

saved two times.  There are only two fields in Carts Table, one is "CartID"

which is autonumber and the second is "UserID" numeric.  Below is a piece of

my code.  Do you think there is something wrong with my code?



Set rsUser = Nothing



   Dim rsCartID

   Set rsCartID = Server.CreateObject("ADODB.Recordset")

   strSQL = "SELECT * FROM Carts"

   rsCartID.Open strSQL, ObjConn, adOpenStatic, adLockOptimistic, adCmdText



   rsCartID.Addnew

   rsCartID("UserID") = Session("UserID")

   rsCartID.Update



   rsCartID.close

   Set rsCartID = Nothing

  objConn.Close

  Set objConn = Nothing





Thanks,



Enzo



Message #2 by "Daniel O'Dorisio" <dodorisio@o...> on Wed, 24 Oct 2001 16:19:46 -0400
not that i can see..



but you would be much better off using SQL INSERT statements..



look on www.w3schools.com for more info on the INSERT statement.

but the basics are:



ssql = "INSERT INTO carts(userid) VALUES('" & Session("userid") & "')"



then execute it with a connection.



daniel



-----Original Message-----

From: Enzo Zaragoza [mailto:enzaux@g...]

Sent: Wednesday, October 24, 2001 4:02 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Record Saved Twice





I was wondering why is it that everytime I add a new record for Carts it is

saved two times.  There are only two fields in Carts Table, one is "CartID"

which is autonumber and the second is "UserID" numeric.  Below is a piece of

my code.  Do you think there is something wrong with my code?



Set rsUser = Nothing



   Dim rsCartID

   Set rsCartID = Server.CreateObject("ADODB.Recordset")

   strSQL = "SELECT * FROM Carts"

   rsCartID.Open strSQL, ObjConn, adOpenStatic, adLockOptimistic, adCmdText



   rsCartID.Addnew

   rsCartID("UserID") = Session("UserID")

   rsCartID.Update



   rsCartID.close

   Set rsCartID = Nothing

  objConn.Close

  Set objConn = Nothing





Thanks,



Enzo





Message #3 by "Enzo Zaragoza" <enzaux@g...> on Thu, 25 Oct 2001 06:26:36 +0800
Thank Daniel! This will be another learning experience for me :)



Enzo



  ----- Original Message -----

  From: Daniel O'Dorisio

  To: ASP Web HowTo

  Sent: Thursday, October 25, 2001 4:19 AM

  Subject: [asp_web_howto] RE: Record Saved Twice





  not that i can see..



  but you would be much better off using SQL INSERT statements..



  look on www.w3schools.com for more info on the INSERT statement.

  but the basics are:



  ssql =3D "INSERT INTO carts(userid) VALUES('" & Session("userid") & 

"')"



  then execute it with a connection.



  daniel



  -----Original Message-----

  From: Enzo Zaragoza [mailto:enzaux@g...]

  Sent: Wednesday, October 24, 2001 4:02 PM

  To: ASP Web HowTo

  Subject: [asp_web_howto] Record Saved Twice





  I was wondering why is it that everytime I add a new record for Carts 

it is

  saved two times.  There are only two fields in Carts Table, one is 

"CartID"

  which is autonumber and the second is "UserID" numeric.  Below is a 

piece of

  my code.  Do you think there is something wrong with my code?



  Set rsUser =3D Nothing



     Dim rsCartID

     Set rsCartID =3D Server.CreateObject("ADODB.Recordset")

     strSQL =3D "SELECT * FROM Carts"

     rsCartID.Open strSQL, ObjConn, adOpenStatic, adLockOptimistic, 

adCmdText



     rsCartID.Addnew

     rsCartID("UserID") =3D Session("UserID")

     rsCartID.Update



     rsCartID.close

     Set rsCartID =3D Nothing

    objConn.Close

    Set objConn =3D Nothing





  Thanks,



  Enzo



Message #4 by "Daniel O'Dorisio" <dodorisio@o...> on Wed, 24 Oct 2001 18:31:17 -0400
SQL INSERTS, UPDATES, and DELETES are the best way to add edit and delete

records. it is much quicker then using ADO .addnew .update and .delete



daniel



-----Original Message-----

From: Enzo Zaragoza [mailto:enzaux@g...]

Sent: Wednesday, October 24, 2001 6:27 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Record Saved Twice





Thank Daniel! This will be another learning experience for me :)



Enzo



  ----- Original Message -----

  From: Daniel O'Dorisio

  To: ASP Web HowTo

  Sent: Thursday, October 25, 2001 4:19 AM

  Subject: [asp_web_howto] RE: Record Saved Twice





  not that i can see..



  but you would be much better off using SQL INSERT statements..



  look on www.w3schools.com for more info on the INSERT statement.

  but the basics are:



  ssql = "INSERT INTO carts(userid) VALUES('" & Session("userid") & "')"



  then execute it with a connection.



  daniel




  Return to Index