Attempting ASP link to Database

  • Thread starter Thread starter H8ids
  • Start date Start date
H

H8ids

Working on dynamically deleting a database entry. Below is the code I'm
running into an error with. There is a column in the database by the name of
"email".
Is it possible for the ASP code to define an ACCESS column as a Form?

<%
' Declaring variables
Dim email, con, data_source, sql_delete
email = Request.Form("email")
sql_delete = "delete email from users where email = '" & email & "'"
data_source = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source = " & _
Server.MapPath("mail.mdb")
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_delete
con.Close
Set con = Nothing
Response.Write "Your email address " & email & _
" was successfully deleted from our database."
%>
 
You cannot delete a column, only a whole row.

If you want to set the email column to blank, then try something like this:

Update users
Set email = Null
where email = '" & email & "'"

Of course, you replace Null with the empty string "", based on the
definition of the email column and the overall logic of your program.
However, under Access, Null is more often used than the empty string.

The above will also reset the values of all other users with the same
e-mail. This might be a concern if there where an error with the provided
email in the first place.

S. L.
 
Back
Top