Delete the record with the help of the record numb

Results 1 to 3 of 3

Thread: Delete the record with the help of the record numb

  1. #1
    Join Date
    Dec 1969

    Default Delete the record with the help of the record numb

    Hi,<BR><BR>I have to delete the particular record that a user selects on the ASP page from the database table.<BR><BR>The way i delete the record right now is, i create a recordset by selecting * from the table, then filter the recordset with the value in the primary key that the user want to delete, (rs.filter= where clause). Now i say rs.delete.<BR><BR>Now The problem is i have duplicate records in my table. Some body told me that each record is uniquely identified by it&#039;s record number.<BR> <BR>How do i get the record number of the record in the ASP and delete the record. (How can i filter the recordset with the record number and then delete.)<BR><BR>Thanks in advance,<BR><BR>Shyam.<BR>

  2. #2
    Join Date
    Dec 1969

    Default Somebody told you a lie...

    Most DBs do *not* automatically assign record numbers to records. And even the ones that do often assign only *transient* numbers, that last only for the duration of the query.<BR><BR>Much more reliable is to assign record numbers yourself.<BR><BR>In Access, you can easily do that by adding another field to the table and using the type "Autonumber". Access will then add the field and assign numbers to each record.<BR><BR>Anyway, you are doing the DELETE in just about the most inefficient way you could. The only thing worse would be to use a WHILE loop to search through the entire recordset.<BR><BR>*MUCH* better to use a SQL Delete query:<BR><BR>&#060;%<BR>conn.Execute( "DELETE FROM tablename WHERE autonumberField = " & numberFromForm )<BR>%&#062;<BR><BR>Presto. Done.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Delete the record with the help of the record

    Ugh... <BR><BR>1)That&#039;s not a good way to delete a record. You should use a sql statement like:<BR><BR>Delete from tablename where id = something<BR><BR>2)If you&#039;re primary key isn&#039;t really a primary key this could delete more than one row. <BR><BR>If that&#039;s not acceptable, uou could add a new field then start updating it using a counter. Now this new field will be your primary key and you can delete duplicate records based on this row. You should figure out how to set up primary keys in the database you&#039;re using and see how your table is set up.

Posting Permissions

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