...

View Full Version : Form to Datbase



saeed
12-07-2007, 11:48 AM
html file.


<html>
<head>
<title></title>
</head>

<body>

<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">
<tr>
<td width="118" align="left" valign="top"><font face="Verdana" size="2">Name:</font></td>
<td><input type="text" name="name" size="30"></td>
</tr>
<tr>
<td width="118" align="left" valign="top"><font face="Verdana" size="2">Email:</font></td>
<td><input type="text" name="email" size="30"></td>
</tr>
<tr>
<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>
</tr>
<tr>
<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>
</tr>
<tr>
<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>
</td>
</tr>
</table>
</form>
</body>

</html>


asp file



<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
'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
connection.Open(sConnString)

'execute the SQL
connection.execute(sSQL)

response.write "Comments are saved successfully."
'Done. Close the connection object
connection.Close
Set connection = Nothing
%>
</body>
</html>


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

thanks,


saeed.

Spudhead
12-07-2007, 12:48 PM
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).

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

appreciated! :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum