Learn how to delete records with an SQL instead of a Recordset. Here are two examples. One will use a query string and the other gets the info from a form. Both examples include an example of a DSN-LESS connection.
Nuts Own Code

Asp Directory

Nuts Web Search
Web Directory
Web Search

Nuts ASP Code
Functions
Scripts
Tutorials
Wizards
Fonts
Download Fonts
Download Dll Files
Dll Files
Relaxing Games
Online Games
Take Our Poll
Do you use .Net?
Yes
No
Not Yet
Dot What?
Really, Take It!
Get The Source
About Nuts4Asp
Privacy
Contact Us
Arts
Movies, Television, Music
Business
Jobs, Industries, Investing
Computers
Internet, Software, Hardware
Games
Video Games, RPGs, Gambling
Health
Fitness, Medicine, Alternative
Home
Family, Consumers, Cooking
Kids and Teens
Arts, School Time, Teen Life
News
Media, Newspapers, Weather
Reference
Maps, Education, Libraries
Regional
US, Canada, UK, Europe
Science
Biology, Psychology, Physics
Sports
Baseball, Soccer, Basketball
World
Deutsch, Español, Français, Italiano, Japanese, Nederlands, Polska, Svenska
Help build the largest human-edited directory of the web
This example is for using forms and makes some assumptions. Be sure to make the necessary changes.
  1. That you want to use a physical path to the database.
  2. That you use the Access driver, your database is named myDB and the path is on the E drive.
  3. That the table in your database is named myTable, one field is named email and that the field in the form is named textbox1.

<%
Set Conn = Server.CreateObject("ADODB.Connection")
'assumption 1
FilePath = "E:\database\myDB.mdb"
'assumption 2
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & FilePath & ";"

'assumption 3
sql = "DELETE * FROM myTable WHERE email=" & Request.Form("textbox1") 
Conn.execute(sql)
Conn.Close
%> 

This example is for using query strings and makes many of the same assumptions. Again, make the necessary changes.

  1. That you want to use a physical path to the database.
  2. That you use the Access driver, your database is named myDB and the path is on the E drive.
  3. That the table in your database is named myTable, one field is named email and that the query string is named email.

<%
Set Conn = Server.CreateObject("ADODB.Connection")
'assumption 1
FilePath = "E:\database\myDB.mdb"
'assumption 2
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & FilePath & ";"

'assumption 3
sql = "DELETE * FROM myTable WHERE email=" & Request.QueryString("email") 
Conn.execute(sql)
Conn.Close
%> 

Now go find out how to add or edit a record the same way.

There are a few different options in building a DSN-LESS connection to your database. To get a look at them all, check out the connection page.

If you are unsure about using QUERY STRINGS, take a look at this tutorial.

Bad or missing query parameters in request.

Copyright © 2001-2009 Nuts4Asp.com
All other names used are property or copyright of their respective owners.