Solved

Form page and dump into my database

Posted on 2008-10-27
3
171 Views
Last Modified: 2010-05-18
I have SQL Server Express.  I am making a webpage with fields on it such as Name and Address.  I want to take this information and dump it into my SQL Server Express database.  Can someone give me some direction on how to start doing this.  Better yet, do you have any code examples of a very basic webpage that already does this??

0
Comment
Question by:al4629740
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:KenAdney
ID: 22814628
There's several ways to do this.  Here's a somewhat abbreviated example in classic ASP:

<%
IF request.form("datecomplete") <> "" THEN
Set DataConn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
DataConn.Open "Provider=sqloledb;" & _
                  "Data Source=the_server;" & _
                  "Initial Catalog=your_database;" & _
                 "User Id=database_user_ID;" & _
                "Password=database_user_password;"
sql = "SELECT * FROM your_table"
rs.Open sql, DataConn, 1, 3
rs.AddNew
rs.Fields("address")    = request.form("address")
rs.Update
DataConn.Close
Set DataConn = Nothing
Set rs = Nothing
%>
<form action="my_form.asp" method="post">
<p>What's your address? <text name="address"></text></p>
<input type="hidden" name="datecomplete" value='<%= now %>'>
<input type="submit" name="submit" value="Submit this form">
</form>       
0
 

Author Comment

by:al4629740
ID: 22843011
I placed the code in Notepad and saved it as temp.asp

where would I enter the address?  Is there a text box?
0
 
LVL 10

Accepted Solution

by:
KenAdney earned 500 total points
ID: 22843623
The bottom 5 lines of that code is the form where you'd enter the address.

In short, you have a standard html form with one hidden field (in this case, called datecomplete) and the form "posts" to itself (the same page).  There's an IF...THEN at the top that says if datecomplete has a value then add everything to the database (because your user must have filled everything out and submitted it) but if the datecomplete is blank (as would be the case when the page first loads) then display the html form.

The hard part is that this is server side code, so it has to be on a server (that supports ASP) to display properly.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn how to count occurrences of each item in an array.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question