Codefixer - ASP tutorials, resources and software
ASP.NET 3.5/2.0 Hosting – Click Here
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Tuesday 13 May
MembersPro PayPal - ASP Membership software

asp.netPRO “Best ASP.NET Host” – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

Form to database Part 2

The code below will show all the records that you have entered into your form. (See Part 1)

Call our file 'show_records.asp'.

<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database - showing records</title>
</head>
<body>
<%
'declare your variables

Dim connection, recordset
Dim sSQL, sConnString

'declare SQL statement that will query the database
sSQL="SELECT * FROM Users_tbl"

'create an ADO connection and recordset object
Set connection = Server.CreateObject("ADODB.connection")
Set recordset = Server.CreateObject("ADODB.Recordset")

'define the connection string, specify database
'driver and the location of database

sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("Users.mdb")

'Open the connection to the database
Connection.Open sConnString

'Open the recordset object, executing the SQL
Recordset.Open sSQL, Connection

'Looping through the records until the end of the records
Do while Not recordset.eof
Response.Write "Name : " & recordset("name") & "<br>"
Response.Write "Email : " & recordset("email") & "<br>"
Response.Write "Comments : " & recordset("comments") & "<br><br>"
'move on to the next record
recordset.MoveNext
loop

'Now close the recordset and the connection object
recordset.Close
Set recordset = Nothing
connection.Close
Set connection = Nothing
%>
</body>
</html>


Previous: INSERT Form Content to Database (Part 1)
LinksPro - Directory  and Link  Management Software




ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software