|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I want to delete the records of my database table by checking checkbox & clicking delete button,my code is given below ,but it is giving error,it takes me a lot of time,if anyone has solution for it ,be foward for it.......
thanks <% if Not IsEmpty(Request.Form("cbDel")) Then strTrans = trim(request.form("chkDel")) & "," arrTrans = split(strTrans,",") Set conn1 = server.createobject("ADODB.Connection") 'change With your own connection conn1.open "my_conn",session("db_user"),session("db_pass") For i = 0 To ubound(arrTrans) - 1 cKd=trim(arrTrans(i)) sql="delete my_article where art_id = '" & cKd & "'" conn1.execute(sql) Next conn1.close Set conn1=nothing End if Set rs = Server.CreateObject("ADODB.RecordSet") fp_sQry= "Select * From my_article Order By art_name" cPass="DSN=my_conn;UID="+session("db_user")+";Password="+session("db_pass") rs.Open fp_sQry, cPass,1,1,1 if request.querystring("mode")="next" Then startno=request.querystring("next") End if if isempty(startno) Then startno=0 End if recnum = rs.recordcount ' cari nomor halaman terakhir vendpage=recnum-(recnum mod 10) if recnum=vendpage Then vendpage=vendpage-10 End if if recnum>0 Then rs.movefirst End if %> <HTML> <HEAD> <SCRIPT language="javascript"> <!-- function CheckItem() { if (! isNaN(frmpt.chkDel.length)) { For (var i=0; i<=frmpt.chkDel.length-1;++i) { if (frmpt.chkDel[i].checked) return 1; }; } Else { if (frmpt.chkDel.checked) return 1; }; return 0 }; function ActionDel() { if (CheckItem()) { if(confirm("Selected records will be deleted. Are you sure?")) { frmpt.cbDel.value="1"; frmpt.submit(); }; } Else {alert("No records selected!")}; }; //--> </SCRIPT> <TITLE>Article</TITLE> </HEAD> <BODY topmargin=0> <TABLE width="100%" border="0" cellspacing="0" cellpadding="0"> <TR> <TD width="26%"> </TD> <TD width="46%"> <DIV align="center"><FONT face="Verdana, Arial, Helvetica, sans-serif" size="5"><B>Article</B></FONT></DIV> </TD> <TD width="28%" align="right" valign="top"></TD> </TR> </TABLE> <FORM method="POST" action="mnt_art.asp" name="frmpt"> <DIV align="center"> <CENTER> <TABLE width="454" border="0" cellspacing="0" cellpadding="0" height="25"> <TR> <TD></TD> </TR> </TABLE> <TABLE border="0" width="454" height="1" cellpadding="0" cellspacing="1"> <TR> <TH width="408" height="1" align="left" bgcolor="#000000"><FONT color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="2"> Article</FONT></TH> <TD width="59" height="1" align="left" bgcolor="#000000"> </TD> </TR> <% if Not rs.eof Then rs.Move startno End if vpage=(startno/10)+1 if ((recnum/10)-(recnum\10) > 0) Then limit = (recnum\10)+1 else limit = (recnum\10) End if mvar=0 nn=0 Do While Not rs.Eof if nn=0 Then startno=startno+1 mvar=mvar+1 nn=1 %> <TR bgcolor="#CCCCCC"> <TD width="59" height="22"><%=Trim(rs.Fields("keterangan"))%></TD> <TD> <INPUT type="checkbox" name="chkDel" value="<%=rs("art_id")%>"> </TD> </TR> <% Else ' nn=1 startno=startno+1 mvar=mvar+1 nn=0 %> <TR> <TD width="408" height="22"><%=Trim(rs.Fields("keterangan"))%></TD> <TD width="59" height="22"> <INPUT type="checkbox" name="chkDel" value="<%=rs("art_id")%>"> </TD> </TR> <% End if rs.MoveNext if startno mod 10=0 Then Exit Do End if Loop %> <TR> <TD height="1" style="border-bottom: thin none" valign="middle" width="408"><FONT face="Verdana, Arial, Helvetica, sans-serif" size="1"> <% if recnum>0 Then response.write("Page :") End if %> <% if startno > 10 Then if rs.eof and (rs.recordcount mod 10)<>0 Then prevstartno=rs.recordcount-(rs.recordcount mod 10)-10 else prevstartno=startno-20 End if if prevstartno<0 Then prevstartno=0 End if else prevstartno=0 End if if startno>10 Then response.write "<A href='mnt_art.asp?next=0&mode=next'><FONT face='Verdana' size='-2'>|<</FONT></A> " if (vpage>2) Then response.write "<A href='mnt_art.asp?next="& prevstartno &"&mode=next'><FONT face='Verdana' size='-2'><<</FONT></A> " End if response.write " " End if number_ctr=0 jumpno=0 For i=1 To recnum step 10 number_ctr=number_ctr+1 if vpage=number_ctr Then response.write "<B>"& Cstr(number_ctr) &"</B> " a=1 Else if (number_ctr < limit-9) Then if (number_ctr > vpage) Then a1=a1+1 response.write "<A href='mnt_art.asp?next="& jumpno &"&mode=next'>"& Cstr(number_ctr) &"</A> " End if Else response.write "<A href='mnt_art.asp?next="& jumpno &"&mode=next'>"& Cstr(number_ctr) &"</A> " a1 = a1 + 1 End if End if if a1=10 Then Exit For End if jumpno=jumpno+10 next if Not rs.eof Then response.write " " if (number_ctr > vpage+1) Then response.write " <A href='mnt_art.asp?next="& startno &"&mode=next'>>></A>" End if response.write " <A href='mnt_art.asp?next="& vendpage &"&mode=next'>>|</A>" End if 'End counting page %> </FONT> </TD> <TD height="1" style="border-bottom: thin none" valign="middle" width="59"> <INPUT type="hidden" value="Delete" name="cbDel"> <INPUT type="button" value="Delete" name="cbDel2" onClick="ActionDel()"> </TD> </TR> <TR> <TD colspan="2" height="1" style="border-bottom: thin none" valign="middle"> </TD> </TR> </TABLE> </CENTER></DIV> </FORM> <P> </P> </BODY> </HTML> |
|
#2
|
||||
|
||||
|
Could you tell us what line the error is on so we don't have to read your whole code! Thanks
|
|
#3
|
|||
|
|||
|
From starting asp tag,the lines goes to 16,coding is below,there are 4 error among them this is first one, its giving script error,
fp_sQry= "Select * From my_article Order By art_name" Thanks |
|
#4
|
||||
|
||||
|
Okay, check the following:
1) Spelling 2) art_name is in the table my_article If those are correct, then get rid of the order by and see if it works. Let me know! |
|
#5
|
||||
|
||||
|
Is your DB connection valid? Meaning can you get any info from your DB?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Deleting DB records using checkbox & button |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|