ASP Insert

Associate
Joined
12 Jun 2005
Posts
836
Location
Newcastle
I am doing a knowledge base for Uni. I have a form, which when submitted will insert a record into a Access Database backend, then diverts to another page which should show the entered data.

I have tried a redirect to a page which shows ASP Dynamic data, which is just blank. Im guessing this is because the form that entered the data in is now blank because the data has been submitted?
 
Sounds like you'll either have to store the values in Session or retrieve the PK of the saved row in the database and then use this to lookup the info from the database on your other page.
 
Because i have 2 projects to do in 2 months, and i do not need to learn ASP as i do not use it. This is a part of my degree i have no interest in, and dont use in my day to day job as a System Admin.

Btw, solved the problem, with a Select statement.
 
While it has been solved I woulda used something similar to this.

This was a small piece of registration code I used in a DVD website for a college project.

First the registration page ->

Code:
<form id="Sub" name="Subscription" method="post" action="Subscribe.asp">
  <label>
  <label class="Title">
  <strong>Salutation</strong>
  <br>
  <select name="Salutation">
    <option>Master</option>
    <option>Miss</option>
    <option>Mr</option>
    <option>Mrs</option>
    <option>Ms</option>
  </select>
  </label>
  <p>
    <label><label class="Title">
    <strong>Forename</strong>
    <br>
    <input type="text" name="Forename" />
    </label>
</p>
  <p>
    <label><label class="Title">
    <strong>Surname</strong><br>
    <input type="text" name="Surname" />
    </label>
</p>
  <p>
    <label><label class="Title">
    <strong>Email Address</strong><br>
    <input type="text" name="Email" />
    </label>
</p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>

Then this is the asp based page ->

Code:
<%
'Retrieve the variables from the form
Salutaion 	= 	Request.Form( "Salutation" )
Forename 	= 	Request.Form( "Forename" )
Surname	=	Request.Form( "Surname" )
Email		=	Request.Form( "email" )
%>

<%
'Open the database connection
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("Members.mdb")
%>

<%
'Add new member
sqlAddMember = "INSER INTO Members (Salutation, Forename, Surname, Members Email Address)
VALUES ( '" & Salutation &"', "& Forname & ", '" & Surname & ", '" & Email &"')"
con.Execute sqlAddMember

'Display confirmation message to the user.
Response.Write(Salutation & Surname & " you have been successfully added to our email list")
%>

Basically the user submits their data which is then passed to the asp page for processing and then printed to screen.
Worked everytime!

Out of curiosity where do you work as a Systems Admin?
 
Back
Top Bottom