Link to home
Start Free TrialLog in
Avatar of jamesjs
jamesjs

asked on

FrontPage Form writting to database

I have a Form written with FrontPage 2002 that displays the data to another form.  How do I make the second form submit the data to a database?
I use the <%response.write(request.form("address"))%>
to get the data to be viewable on the second form. Am I not bringing over the data to the seond form that why I can get it to post to databse?
Avatar of drnadeem
drnadeem

listening
I usually code this directly as an Active Server Page (ASP).  The page has to have an .asp file extension and you can look at your code to be sure that it's making a connection to the database and doing the update.

Here's a one version of code that makes a connection to an Access database (this would all be inside a <% %> except for my comments which begin with a -).

Set DataConn = Server.CreateObject("ADODB.Connection")
- this says you're going to make a connection

Set rs = Server.CreateObject("ADODB.Recordset")
-this says you're creating a recordset

DataConn.Open "DBQ=" & Server.Mappath("database.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
-this tells the server what kind of database

sql = "SELECT * FROM sometable"
-this is a basic SQL statement for getting the particular table you want to update

rs.Open sql, DataConn, 1, 3
-this opens the connection & matches the SQL statement with the connection and the recordset

rs1.AddNew
-what you want to do with the data - i.e. add it

if request.form("data") <> "" then rs.Fields("data")    = request.form("data")

-if the form field "data" isn't blank then update the table field "data" with it's contents

rs.Update
-make the update

You should also have some code about closing the connection to the database.  Hope this helps.
ASKER CERTIFIED SOLUTION
Avatar of hhammash
hhammash

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jamesjs

ASKER

When I go to the form properties and then options I don't see any of the form fields to be saved that I want to collect from the form.  And the add button is greyed out.
Hi,

No need. OK,  I will put the full steps as an example of mine.

Scenario:
---------
I have a database with one table that has the following fields: Name,Department,Supervisor.

I have a form called Submit.asp and another form called Verify.asp.  The user will fill in the Sumbit.asp and presses Submit.  Then it goes to the Verify.asp form where all the information entered in the first form are automatically displayed on the second for verification before submitting to the database.

Create the forms:
-----------------
Submit.asp
----------
Open a new page
Inser Form
Line 1: Type Name:
Insert/Form/Textbox after the Name:
Double click the Textbox and name it as Name
Line 2: Type Department:
Insert/Form/Textboxk after the Department:
Doubl click the textbox and name it as Department
Line 3: Type Supervisor:
Insert/Form/Textbox after the Supervisor:
Double click the textbox and name it as Supervisor
Right click the form,  select properties
Select Send to Other
Click Options
In Action Put: Verify.asp
Save the form as Submit.asp

Verify.asp
----------
Open a new page
Insert form
Line 1: Same as above exactly in line 1 of Submit.asp then when you double click the Textbox name it as Name and in the value under it put: <%=request.form("Name")%>

Line 2: Same as above in line 2 of Submit.asp then when you double click the text box name it as Department,  then under it in the value put: <%=request.form("Department")%>

Line 3: Same as above in line 3 of Submit.asp then when you double click the text box name it as Supervisor, then under it in the value put: <%=request.form("Supervisor")%>

Right Click the form
Select Properties
Send to Database
Click Options
Select the Database Connection
Select the Data source (which table)
Then go to saved fields and verify each one.
Save the page as Verify.asp

Now when you open Submit.asp and fill the form,  then click submit,  the data will be send to Verify.asp,  if the user has any changes he/she can make them here then press submit to send the data to the database.

Regards
hhammash
Avatar of jamesjs

ASKER

You helped me again.

Thank you so much..
your solution also helped me.   Question when the submit form has drop down menu selection of items, how do you populate the second form with that info..   Or can you only do this with "text box" fields

thank you
bruce
Hi bruce,

Just mention the name of the drop down menu like you do with the text field.

<%=request.form("DropDownMenuName")%>

hhammash