ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 28th, 2003, 10:23 AM
coooldesign coooldesign is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: India
Posts: 3 coooldesign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Deleting DB records using checkbox & button

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>

Reply With Quote
  #2  
Old December 29th, 2003, 09:19 AM
WisconsinGuy's Avatar
WisconsinGuy WisconsinGuy is offline
I thank you very little
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2003
Location: Milwaukee, WI
Posts: 1,028 WisconsinGuy User rank is Corporal (100 - 500 Reputation Level)WisconsinGuy User rank is Corporal (100 - 500 Reputation Level)WisconsinGuy User rank is Corporal (100 - 500 Reputation Level)WisconsinGuy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 35 m 41 sec
Reputation Power: 9
Could you tell us what line the error is on so we don't have to read your whole code! Thanks

Reply With Quote
  #3  
Old December 30th, 2003, 01:56 AM
coooldesign coooldesign is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: India
Posts: 3 coooldesign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old December 30th, 2003, 08:49 AM
WisconsinGuy's Avatar
WisconsinGuy WisconsinGuy is offline
I thank you very little
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2003
Location: Milwaukee, WI
Posts: 1,028 WisconsinGuy User rank is Corporal (100 - 500 Reputation Level)WisconsinGuy User rank is Corporal (100 - 500 Reputation Level)WisconsinGuy User rank is Corporal (100 - 500 Reputation Level)WisconsinGuy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 35 m 41 sec
Reputation Power: 9
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!

Reply With Quote
  #5  
Old December 30th, 2003, 08:50 AM
WisconsinGuy's Avatar
WisconsinGuy WisconsinGuy is offline
I thank you very little
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2003
Location: Milwaukee, WI
Posts: 1,028 WisconsinGuy User rank is Corporal (100 - 500 Reputation Level)WisconsinGuy User rank is Corporal (100 - 500 Reputation Level)WisconsinGuy User rank is Corporal (100 - 500 Reputation Level)WisconsinGuy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 35 m 41 sec
Reputation Power: 9
Is your DB connection valid? Meaning can you get any info from your DB?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Deleting DB records using checkbox & button


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT