Forum Moderators: open
Here is my question, I want to email a password out of my database.
Here is basic operation I want to happen
-Customer fills out registration form and clicks submit
-asp page processes form and enters customer data into database (already know how to do that)
-Database has a autonumber field in it so that when the customer info is added then it gives a number
-The same asp page prepares to send an email grabbing the email address off of the form (already know how to do that)
-in the body of the email there is code written that goes to the database and pulls that autonumber for that particlar customer and inserts it into the body of email(THIS IS WHAT I DONT KNOW HOW TO DO)
Any help? Thanks!
Glad you got things working. Feels great doesn't it? Getting the autonumber back out of Access can be a bit of a challenge. Here's what I found
[adopenstatic.com...]
Hope this helps point you in the right direction - I think the part you're looking for is:
-----------
sql = "INSERT INTO members (whatever) VALUES ('" & also_whatever & "')"
connection.Execute sql
sql = "SELECT @@Identity"
Set objRS = objConn.Execute(sql)
intID = objRS.Fields.Item(0).Value
-----------
According to the author, intID will now contain the autonumber value. I have never tried this - but I presume it works. If not, use SELECT to get the data back after you insert it. NOTE: Autonumbers in Access for such purposes should be random, not incremental to make it hard for someone to guess someone else's number. You may also need adovbs for this - a file I can help you find if needed. Good luck.
It certainly works fine that way with ASP.Net This also saves an extra trip to the database to recover the password.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ language="VBScript" %>
<html>
<head>
<title>first asp</title>
</head>
<body>
<%
Set connection = Server.CreateObject("ADODB.Connection")
connection.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
server.MapPath("data\login2.mdb")
connection.Open
sql="INSERT INTO member (username, [password])"
sql=sql & "VALUES"
sql=sql & "('" & Request.Form("username") & "',"
sql=sql & "'" & Request.Form("password") & "')"
connection.Execute sql
sql = "SELECT @@Identity"
Set objRS = objConnection.Execute(sql)
intID = objRS.username.Item(0).Value
response.write(intID)
response.write(sql)
on error resume next
connection.Execute sql
if err<>0 then
Response.Write(Err.Description)
else
response.write("Record was updated!")
end if
connection.close
%>
</body>
</html>
HEre is the Error Message:
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/get_pwd.asp, line 24
Thanks for your time