Problem with ADO Delete

Results 1 to 2 of 2

Thread: Problem with ADO Delete

  1. #1
    Join Date
    Dec 1969

    Default Problem with ADO Delete

    Hi there,<BR><BR>I have problem deleting all the records in a temp table. My code are as follows:<BR><BR>Set delDC = Server.CreateObject("ADODB.Recordset")<BR>delDC.Op en "tempStock",DataConn,adOpenKeyset,adLockPessimisti c,<BR>adCmdTable<BR> If Not delDC.EOF Then<BR> delDC.MoveFirst<BR> Do While not delDC.EOF<BR> delDC.delete adAffectCurrent<BR> delDC.MoveNext<BR> Loop<BR> End if<BR><BR>If there&#039s one record in the table, it will not be deleted at all. And if there are for example 3 records, only 2 will be deleted.The result is always short of one being deleted.<BR><BR>Are there something wrong with my code or that i have missed out something?<BR><BR>Thanx.

  2. #2
    Join Date
    Dec 1969

    Default RE: Problem with ADO Delete

    I don&#039t know why you are seeing that strange behavior. Although I am suspicious about the completely useless and unnecessary MoveFirst call (and the IF statement, for that matter).<BR><BR>HOWEVER...<BR><BR>That&#039s a pretty darned inefficient way to delete records, one at a time! That means you will end up doing a "round trip" from ASP to the DB server once for each record.<BR><BR>Why not use just a *little* bit of SQL and simply do:<BR><BR>&#060;%<BR>DataConn.Execute("DELETE FROM tempStock")<BR>%&#062;<BR><BR>Presto, all records gone in one statement.<BR><BR>I might recommend this page to you, too:<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts