0

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

2
Contributors
2
Replies
5
Views
5 Years
Discussion Span
Last Post by mrbarbarik
0

t

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.

0

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

-display.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>";

        rs.move(1);
     }Response.Write(out);
  %>

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:

-delete.asp-

<%
 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>";
}
else
{out = "<tr> <td> Record Not Found! </td> </tr>";}

Response.Write ( out );
%>

Edited by mrbarbarik: xx

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.