The first thing you need to do is create a database called MyCustomers. Then create a table called tblCustomerInfo with these fields:
ID - autonumber
Email - text field
Name - text field
DateEntered - date/time field
Next, create a form page called formpage.asp and copy the below code into your page:
Then, create a page called resultspage.asp and copy the below code into your page:
<% DIM objRS Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open "tblCustomerInfo", objConn, , adLockOptimistic, adCmdTable objRS.AddNew objRS("Email") = Request.Form("Email") objRS("Name") = Request.Form("Name") objRS("DateEntered") = Date() objRS.Update DIM bookmark bookmark = objRS.absolutePosition objRS.Requery objRS.absolutePosition = bookmark DIM strCustomerID strCustomerID = objRS("ID") %>
Thank you for reigstering with us. Here is your Customer ID: <% =strCustomerID %>
<% objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing %>
There you have it. Now you can insert a record and retrieve its unique id and display it on your page all in one fell swoop!
http://www.aspwebpro.com/aspscripts/database/retrieveuniqueid.asp
No comments:
Post a Comment