ASP 101 - Active Server Pages 101 - Web06
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

ASP Source Code:
Const adVarChar = 200
Const adBoolean = 11
Dim rstUserData
' Normally this would be the result of a query something like this:
'    SELECT * FROM TableName WHERE id=123;
' or:
'    SELECT * FROM TableName WHERE email LIKE 'EmailAddressGoesHere';
' For simplicity, my recordset isn't actually connected to anything.
' Create the stand alone recordset
Set rstUserData = Server.CreateObject("ADODB.Recordset")
rstUserData.Fields.Append "Name", adVarChar, 50
rstUserData.Fields.Append "Email", adVarChar, 100
rstUserData.Fields.Append "Updates", adBoolean
' Add the sample data to our recordset.  Again, this data would
' normally be a result of a query against your database.
rstUserData.Fields("Name").Value = "John"
rstUserData.Fields("Email").Value = "JohnsEmailWouldGoHere"
rstUserData.Fields("Updates").Value = True
If Request.Form("save") = "Save" Then
	' Save data from the form back to the recordset.
	rstUserData.Fields("Name").Value = Request.Form("name")
	rstUserData.Fields("Email").Value = Request.Form("email")
	rstUserData.Fields("Updates").Value = (Request.Form("updates") = "on")
	Data updated.  You can continue making chages via the form below or
	<a href="<%= Request.ServerVariables("SCRIPT_NAME") %>">start over</a>.
End If ' Else
	' Display the form with the data from the recordset.
	' If the user just saved the data, you might not want to show the
	' form again.  In that case change the "End If" above to an "Else"
	' and uncomment the last "End If" on the page.
	If Not rstUserData.EOF Then
	<form action="<%= Request.ServerVariables("SCRIPT_NAME") %>" method="post">
	<table border="0">
			<td align="right"><strong>Name:</strong></td>
			<td align="left"><input type="text" name="name" size="30" value="<%= rstUserData.Fields("Name").Value %>" /></td>
			<td align="right"><strong>Email:</strong></td>
			<td align="left"><input type="text" name="email" size="30" value="<%= rstUserData.Fields("Email").Value %>" /></td>
			<td align="right"><strong>Send Me Updates:</strong></td>
			<td align="left"><input type="checkbox" name="updates"
				<% If rstUserData.Fields("Updates").Value Then Response.Write "checked=""checked""" %> />
			<td> </td>
				<input type="reset" value="Reset" />
				<input type="submit" name="save" value="Save" />
	End If
' End If

Back the the Sample Output

Back to the Sample Index

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers