View Full Version : Form to Datbase

12-07-2007, 10:48 AM
html file.



<p align="center"><b><font face="Verdana">Data Entry Form</font></b></p>
<form method="post" action="add_to_database.asp">
<table border="0" width="70%" id="table1">
<td width="118" align="left" valign="top"><font face="Verdana" size="2">Name:</font></td>
<td><input type="text" name="name" size="30"></td>
<td width="118" align="left" valign="top"><font face="Verdana" size="2">Email:</font></td>
<td><input type="text" name="email" size="30"></td>
<td width="118" align="left" valign="top"><font face="Verdana" size="2">Comment:</font></td>
<td><textarea rows="9" name="comments" cols="25"></textarea></td>
<td width="118">&nbsp;</td>
<td><input type="button" value="Add" name="bt_add">
<input type="button" value="Edit" name="bt_Edit">
<input type="submit" value="Save" name="bt_Save">
<input type="button" value="Delete" name="bt_Delete">
<input type="button" value="Update" name="bt_Update">
<td width="118">&nbsp;</td>
<td><input type="button" value="&lt;&lt; First" name="bt_First">
<input type="button" value="&lt; Previous" name="bt_Previous">
<input type="button" value="Next &gt;" name="bt_Next">
<input type="button" value="Last &gt;&gt;" name="bt_Last">
<p><a href="javascript:window.close()">Exit the System</a></p>


asp file

<%@ Language="VBScript" %>
<% Option Explicit %>
<title>Form to database</title>
'declare your variables
Dim name, email, comments
Dim sConnString, connection, sSQL
'Receiving values from Form, assign the values entered to variables
name = Request.Form("name")
email = Request.Form("email")
comments =Request.Form("comments")

'declare SQL statement that will query the database
sSQL = "INSERT into users_tbl (name, email, comments) values ('" & _
name & "', '" & email & "', '" & comments & "')"
'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")
'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")

'Open the connection to the database

'execute the SQL

response.write "Comments are saved successfully."
'Done. Close the connection object
Set connection = Nothing

can someone help me with displaying records.. I want records displaying through Previous Next First and Last button.



12-07-2007, 11:48 AM
If you want previous and next buttons, I'd start by reading a few tutorials on paging in ASP (http://www.google.co.uk/search?q=ASP+paging).

12-07-2007, 12:30 PM
thanks man

appreciated! :thumbsup:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum