Hi all,

I'm newbie in asp.
I have a problem to delete the record on sql. I have one form for different users to insert data into sql where every user have are unique id, so it's possible to have multiple record with same unique id, then display the data recorded using while loop, so it will display all recorded data in sql based on that unique id.

I have placed a delete link in that while loop, so every data displayed will have link to delete it. The problem is, when I clicked the delete link on all data displayed except the first data displayed(data on the top), it will delete the first data displayed not the data I clicked.

So, anyone can help..please


we need to see your code. it sounds like the functions 3mbeded in the delete links have simply been replicated from the first link. it remains unclear until we see some code.

this is the code to display data, when link Delete clicked, it will redirect to page delete.asp:


<%   var out ="";
    while ( ! rs.EOF )
    {   out += "<table><tr>";
        out += "<td width=75 bgcolor='#666666'>Catatan</td>";
        out += "<td bgcolor='#999999' width='300'>";
        out += String(ss.fields.item("catatan"));
        out += "</td></tr>";
        out += "<tr>";
        out += "<td width=75 bgcolor='#666666'>Kelulusan</td>";
        out += "<td bgcolor='#999999' width='300'>";
        out += String(ss.fields.item("kelulusan"));
        out += "</td></tr>";
        out += "<tr><td colspan=2><a href='delete.asp'>Delete</a></td></tr>";
        out += "</table>";


this is to delete data. The data to delete is displayed to confirm the delete process before user press button delete. This also the problem because it displayed the first top data, not the data I clicked. I think, it delete the first data found in database which the unique id match the condition:


 var out = "";
if ( ! rs.EOF )
 out += "<table><tr><td><u>Catatan : </u></td>";
 out += "<td>";
 out += String(rs.fields.item("catatan"));
 out += "<input type='hidden' name='ctt' value='"+String(rs.fields.item("catatan")) +"'>";
 out += "</td></tr>";
 out += "<tr><td><u>Kelulusan : </u></td>";
 out += "<td>";
 out += String(rs.fields.item("kelulusan"));
 out += "<input type='hidden' name='kls' value='"+String(rs.fields.item("kelulusan")) + " '>";
 out += "</td></tr></table>";              
 out += "<p><input type='submit' name='button' value='Delete'></p>";
{out = "<tr> <td> Record Not Found! </td> </tr>";}

Response.Write ( out );
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.