Wrox Home  
Search P2P Archive for: Go

  Return to Index  

interdev_programming thread: Using VI and ASP to update Access table


Message #1 by "Cathy L. Price" <cathyp@l...> on Tue, 29 Oct 2002 14:44:50
Hello Cathy,
   Myself is Prasanna , try this code to add new record in databse, This 
Code will surely solve ur problem, Please feel free to e-mail me,


To do this, you first need to create a database called MyData. Then create a 
table called tblContact with these fields:
ID - autonumber
Email - text field
FirstName - text field
LastName - text field
Comments - memo field
DateContacted - date/time field


Next, create a form page called form.asp and copy the below code into your 
page:

<form name="YourFormName" method="Post" action="confirm.asp">
<table>
<tr><td>Email: </td>
<td><input type="text" name="Email" size="50"></td></tr>
<tr><td>First Name: </td>
<td><input type="text" name="FirstName" size="50"></td></tr>
<tr><td>Last Name: </td>
<td><input type="text" name="LastName" size="50"></td></tr>
<tr><td>Comments: </td></tr>
<tr><td><textarea cols="50" name="Comments" ></textarea></td></tr>
</table>

<input type="submit" name="Submit" value="Submit">


Then, create a page called confirm.asp and copy the below code into your 
page:

<!--#INCLUDE VIRTUAL="/includes/connection.asp" -->

<%
DIM objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "tblCustomerInfo", objConn, , adLockOptimistic, adCmdTable

objRS.AddNew
objRS("Email") = Request.Form("Email")
objRS("FirstName") = Request.Form("FirstName")
objRS("LastName") = Request.Form("LastName")
objRS("Comments") = Request.Form("Comments")
objRS("DateContacted") = Date()
objRS.Update
%>

<p>
<%
DIM strFirstName
strFirstName = Request.Form("FirstName")
%>,<br>
</p>

<%
objRS.Close
Set objRS = Nothing
objCONN.Close
Set objCONN = Nothing
%>





_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


  Return to Index