PHP.TheDemoSite.co.uk

 
asp code examples with database connectivity

ASP.TheDemoSite.co.uk

  Just examples of ASP code, linking to your Microsoft Access database and JavaScript.
|1. Home |2. The Database |3. Add a User |4. Login |5. Get your db online|

asp code examples with database connectivity

FREE download-these asp demo-pages FREE Download
complete login
example

Size: 54 Kbytes
Example of a
ASP email contact form
using active server pages:
ASP-Contact-Us
free asp-contact-us FREE Download the complete
ASP-Contact-Us

mail form

Size: 3 Kbytes

This page shows the ASP and JavaScript code used in the "Add a User" section.

addauser.asp

<!--#INCLUDE FILE="header.inc"-->
<!--#INCLUDE FILE="validateform.inc"-->
<blockquote>
<p>Below is the current single record within the database: </p>
</blockquote>

<blockquote>
<blockquote>
<!--#INCLUDE FILE="getrecord.inc"-->
</blockquote>
</blockquote>

<blockquote>
<p>Add your own username and password, enter your details below and click save.&nbsp; <strong>DO
NOT</strong> use valid details as the details you enter will be displayed above and the
next visitor will view them as you are now.</p>
</blockquote>

<form ACTION="savedata.asp" name="saveform" METHOD="POST" align="center">
<div align="center"><center><table border="0" height="59" width="314" bgcolor="#800080"
cellspacing="1" cellpadding="0">
<tr>
<td width="248" height="19" bgcolor="#C0C0C0"><div align="right"><p><font color="#000000"><small>Your
test username:</small></font></td>
<td width="123" height="19" bgcolor="#C0C0C0"><div align="left"><p><input NAME="username"
VALUE SIZE="8" MAXLENGTH="16" tabindex="1"></td>
<td width="51" height="19" bgcolor="#C0C0C0" align="center"><div align="center"><center><p><a
href="javascript:alert('The username must be between 4 and 16 characters long.')"><small><small>Help</small></small></a></td>
</tr>
<tr align="center">
<td width="248" height="17" bgcolor="#C0C0C0"><div align="right"><p><font color="#000000"><small>Your
test password:</small></font></td>
<td height="17" width="123" bgcolor="#C0C0C0"><div align="left"><p><input type="password"
name="password" size="8" tabindex="2" maxlength="8"></td>
<td width="51" height="17" bgcolor="#C0C0C0" align="center"><a
href="javascript:alert('The password must be between 4 and 8 characters long.')"><small><small>Help</small></small></a></td>
</tr>
<tr align="center">
<td width="248" height="1" bgcolor="#C0C0C0"></td>
<td width="123" height="1" bgcolor="#C0C0C0"><div align="left"><p><input TYPE="button"
NAME="FormsButton2" VALUE="save" ONCLICK="validateForm()" tabindex="3"></td>
<td width="51" height="1" bgcolor="#C0C0C0" align="center"><a
href="javascript:alert('Click to save the details')"><small><small>Help</small></small></a></td>
</tr>
</table>
</center></div>
</form>

<p align="center">&nbsp;</p>

<p align="center"><a href="addausercode.asp">Click here to view the ASP and JavaScript
code</a> used for this page.</p>

<p align="center">&nbsp;</p>
<!--#INCLUDE FILE="footer.inc"-->

 

validateform.inc

 

getrecord.inc

<% @LANGUAGE = VBScript %>
<%
Dim objConn, objRS

Set objConn = Server.CreateObject("ADODB.Connection")
conString = "DBQ=D:\a\s\aspthedemosite\private\example.mdb"
objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};" & conString

Set objRS = Server.CreateObject("ADODB.RecordSet")
strQ = "SELECT * from members"
objRS.Open strQ, objConn

While Not objRS.EOF
Response.Write "<b>The username:</b> " & objRS("username") & "<br>"
Response.Write "<b>The password:</b> " & objRS("password")
objRS.MoveNext
Wend

objRS.close
objConn.close
Set objRS = Nothing
Set objConn = Nothing
%>

 

savedata.asp

<% @LANGUAGE = VBScript %>
<%
Dim objConn, objRS, strQ

Set objConn = Server.CreateObject("ADODB.Connection")
conString = "DBQ=D:\a\s\aspthedemosite\private\example.mdb"
objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};" & conString

Set objRS = Server.CreateObject("ADODB.RecordSet")
strQ = "SELECT * from members"
objRS.Open strQ, objConn

strQ = "UPDATE members SET username = '" & Request.Form("username")
strQ = strQ & "', password = '" & Request.Form("password") & "'"
strQ2 = "UPDATE members SET username = 'u' where id='1'"

objConn.Execute strQ

objRS.close
objConn.close
Set objRS = Nothing
Set objConn = Nothing
Response.Redirect("addauser.asp")
%>

< Go Back<

UK Windows Hosting
Get your database online with a dependable host
www.Seiretto.com

Windows Managed Dedicated Servers
No hassle managed dedicated servers
No bandwidth limits
www.S4Servers.com



















ASP.TheDemoSite.co.uk is a Microsoft Access database and FREE ASP code example site.
The database and ASP scripts are all hosted on Seiretto Website hosting   Copyright © Contact us.