iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (35)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

August 7, 2008
Wish XML a happy birthday
About
 
August 7, 2008
Poll: How important is SEO to your overal website strategy?
About
 
August 7, 2008
How to Create a Search Feature with PHP and MySQL
WebReference.com
 
August 7, 2008
1 comment
.net
 
August 6, 2008
10 New SEO Reports
About
 
August 5, 2008
Array Creator
EarthWeb.com
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /ASP

Step by step guide to a Database-Driven application 

  Views:    21036
  Votes:    11
by Romeo Marquez 12/13/03 Rating: 

Synopsis:

Here’s a four step tutorial about an application that can collect data, store it in a DB, modify it and delete it.
Pages: firstback1 2 3 forwardlast
The Article

STEP 4 : DELETING RECORDS

To complete the application, let’s delete some records from our data base.

 

 

Once again, we’ll need to do some changes in listing.asp. We’ll also create delete.asp

 

We’ll start by adding one more column to our table in listing.asp

Here’s just the new code for that table, replace this in listing.asp:

 

<%

Dim objRS

Set objRS = Server.CreateObject ("ADODB.Recordset")

objRS.Open "Users", strConnect, adOpenForwardOnly, adLockReadOnly, adCmdTable

 

response.write "<table width='500' border='0' cellpadding='2'><tr bgcolor='#CCD6E0'>" & _

"<td><b>User ID</b></td><td><b>Full Name</b></td><td><b>Email</b></td><td><b>Edit</b>”

“</td><td><b>Delete</b></td></tr>"

While Not objRS.EOF

Response.Write "<tr><td>"

Response.Write objRS("ID") & "</td><td>" &objRS("Name") & " "&objRS("Lastname")& _

"</td><td>"&objRS("Email")&"</td><td><a href='edit.asp?id="&objRS("id")&"'>Edit</a></td>"& _

"<td><a href='delete.asp?id="&objRS("id")&"'>Delete</a></td></tr>"

objRS.MoveNext

Wend

response.write "</table>"

objRS.Close                   

Set objRS = Nothing          

%>

 

Once again, we send the id through the link as a way to tell delete.asp which record to delete.

Here’s the code for delete.asp:

 

<% Option Explicit %>

<!-- #INCLUDE FILE="DBInfo.asp" -->

<%

  Dim objRS, id,strQuery

  Set objRS = Server.CreateObject ("ADODB.Recordset")

  strQuery= "select * from USERS where id="&request.QueryString("id")

  objRS.Open strQuery, strConnect, adOpenStatic, adLockOptimistic, adCmdText

  objRS.Delete

  objRS.Update

  objRS.Close

  Set objRS = Nothing

  response.redirect "listing.asp"

%>

 

So far, you’ll have the following files in your project:

1.       example.mdb

2.       DBInfo.asp

3.       listing.asp

4.       addnew.asp

5.       edit.asp

6.       saveedit.asp

7.       delete.asp


 

With all these files, we have a pretty good draft of a web application.

Hopefully, you did learn from this example and if you have any questions or

need some help, please let me know!

 

On later tutorials, I’ll refer to this same application to add some more cool stuff

(field validation, delete multiple records, add new tables, etc) and build a better application.

 

Do you have any questions?

Write me, Romeo Marquez Guzman romeo@gelattina.com

www.gelattina.com 

 

Pages: firstback1 2 3 forwardlast

Similar/related articles:


 
  Sponsors