You are on page 1of 5

Feedback.

aspx

<%@ Page Language="vb" AutoEventWireup="false"


CodeBehind="sample1.aspx.vb" Inherits="WebApplication1.sample1" %>

<html>
<head>
<title> Adding to database example </title>
<script type="text/javascript">
<!-function validate()
{
if(document.form.name.value=="")
{
alert("Name is missing");
return false;
}
if(document.form.comments.value.length<8)
{
alert("Not enough comments entered");
return false;
}
else
{
return true;
}
}
//-->
</script>

</head>
<body>
<form name="form" method="post" action="save.aspx">
Name: <input type="text" name="name" maxlength="45"> <br>
Comments: <textarea cols="20" rows="8" name="comments"
maxlength="200"> </textarea><br>
<input type="submit" name="Save" value="Submit" onClick="return
validate();">
</form>
</body>
</html>

Save.aspx
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="save.aspx.vb" Inherits="WebApplication1.save" aspcompat="true"
%>

<%
Dim Conn
Dim Rs

Dim sql

Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.Open("C:/Users/PRANAY/Documents/FeedBack.mdb")
'Create an ADO connection and recordset object

Rs = Server.CreateObject("ADODB.Recordset")
'Set an active connection and select fields from the database
sql= "SELECT name, comments FROM tblFeeds;"
Rs.CursorType = 2
Rs.LockType = 3
Rs.Open(sql, Conn) 'Open the recordset with sql query
Rs.AddNew 'Prepare the database to add a new record and add
Rs.Fields("name") = Request.Form("name")
Rs.Fields("comments") = Request.Form("comments")
Rs.Update 'Save the update
Rs.Close
Rs = Nothing
Conn.commitTrans()
Conn = Nothing
response.redirect("view.aspx")
%>

view.aspx
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="view.aspx.vb" Inherits="WebApplication1.view" aspcompat="true"
%>

<%
Dim Conn
Dim Rs
Dim sql
Conn = Server.CreateObject("ADODB.Connection")
Rs = Server.CreateObject("ADODB.Recordset")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.Open("C:/Users/PRANAY/Documents/FeedBack.mdb")

sql = "SELECT name, comments FROM tblFeeds;"


Rs.Open(sql, Conn)
Do While Not Rs.EOF
Response.Write("======================================
=======" & "<br>")
For Each x In Rs.Fields

Response.Write(x.name & ":<font color='red'>" & x.value)


Response.Write("</font>")
Response.Write("<br>")

Next
Rs.MoveNext()

Loop
Rs.Close()
Rs = Nothing
Conn.Close()
Conn = Nothing

%>

You might also like