Professional Documents
Culture Documents
Practical-19 Aim: Create Webpage To Add, Update, Delete Records Form Database Using Objects of ADO Create Database
Practical-19 Aim: Create Webpage To Add, Update, Delete Records Form Database Using Objects of ADO Create Database
Practical-19 Aim: Create Webpage To Add, Update, Delete Records Form Database Using Objects of ADO Create Database
Create Database:
1) Create Database in Microsoft Office Access and give name “Students”
2) Save as this database as Microsoft Office Access 2002-2003 Format. So now its extension
is “.mdb”(Right Click on Database and check Type of File)
3) Create “student” table and create fields as shown in image
4) create webdata folder in C drive and put your database in webdata folder.( so the path will
be c:/webdata/Students.mdb)
1. Student_Entry.html
<html>
<head>
<title>Student Form</title>
</head>
<body>
<form method="post" action="add_Student.asp">
<br>
<P align=center><FONT size=5><U><STRONG>Student
Entry</STRONG></U></FONT></P>
<P align=center>
<A href="Student_Data.asp">VIEW
STUDENTS</A> &
nbsp;
<A
href="Student_Entry.html">INSERT</A>  
;
<A
href="Student_update_select.asp">UPDATE</A>  
;
<A href="Student_delete_select.asp">DELETE</A>
</P>
<hr>
<table align=center border=0>
<tr>
<td><b>Enter Enrollment No:</td>
<td><input type="text" name="eno" maxlength="20"></td>
</tr>
2. Student_Data.asp
<Html>
<head>
<TITLE>Information Tech Dept</TITLE>
<LINK REL="STYLESHEET" HREF="table.css">
</head>
<Body>
<P align=center><FONT size=5><U><STRONG>Student
Record</STRONG></U></FONT></P>
<P align=center>
<A
href="Student_Entry.html">INSERT</A>  
;
<A
href="Student_update_select.asp">UPDATE</A>  
;
<A href="Student_delete_select.asp">DELETE</A>
</P>
<hr>
<%
Dim Conn,objrs,sql
Set Conn = Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open("c:/webdata/Students.mdb")
Set objrs=server.createobject("ADODB.Recordset")
sql="select * from student"
objrs.open sql,conn
%>
<center>
<br>
<font face = 'arial' color = 'blue'><b>Information Technology Department</b></font>
<br>
<TABLE border=1>
<TR>
</TR>
<% do While not objrs.EOF %>
<%="<tr><td>"& objrs("Enrollment_no") %></td>
<%="<td>"& objrs("Student_Name") %></td>
<%="<td>"& objrs("College_Name") %></td>
<%
objrs.Movenext
Loop
objrs.Close
conn.Close
%>
</table>
</body>
</html>
3 add_Student.asp
<%
Dim adoCon
Dim rsAddstudent
Dim strSQL
Set rsAddstudent=Server.CreateObject("ADODB.Recordset")
strSQL="SELECT student.Enrollment_No,
student.Student_Name,student.College_Name FROM student;"
rsAddstudent.CursorType=2
rsAddstudent.LockType=3
rsAddstudent.Open strSQL, adoCon
rsAddstudent.AddNew
rsAddstudent.Fields("Enrollment_No")=Request.Form("eno")
rsAddstudent.Fields("Student_Name")=Request.Form("name")
rsAddstudent.Fields("College_Name")=Request.Form("clg")
rsAddstudent.Update
rsAddstudent.Close
Set rsAddstudent = Nothing
Set adoCon = Nothing
Response.Redirect "Student_Data.asp"
%>
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT student.* FROM student;"
Loop
%>
<%
'Reset server objects
rsstudent.Close
Set rsstudent = Nothing
Set adoCon = Nothing
%>
</table>
</body>
</html>
5. Student_update_form.asp
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsstudent 'Holds the recordset for the record to be updated
Dim strSQL 'Holds the SQL query for the database
Dim lngRecordNo 'Holds the record number to be updated
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT student.* FROM student WHERE S_Id=" & lngRecordNo
6. Student_update_entry.asp
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsUpdateEntry 'Holds the recordset for the record to be updated
Dim strSQL 'Holds the SQL query for the database
Dim lngRecordNo 'Holds the record number to be updated
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT student.* FROM student WHERE S_Id=" & lngRecordNo
'Set the cursor type we are using so we can navigate through the recordset
rsUpdateEntry.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsUpdateEntry.LockType = 3
'Open the tblComments table using the SQL query held in the strSQL varaiable
rsUpdateEntry.Open strSQL, adoCon
'Return to the update select page incase another record needs deleting
Response.Redirect "Student_update_select.asp"
%>
7. Student_delete_select.asp
<html>
<head>
<title>Delete Entry</title>
</head>
<body bgcolor="white" text="black">
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsstudent 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT student.* FROM student;"
Loop
%>
<%
'Reset server objects
rsstudent.Close
Set rsstudent = Nothing
Set adoCon = Nothing
%></table></body></html>
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT student.* FROM student WHERE S_Id=" & lngRecordNo
'Set the lock type so that the record is locked by ADO when it is deleted
rsDeleteEntry.LockType = 3
'Return to the delete select page incase another record needs deleting
Response.Redirect "Student_delete_select.asp"
%>
2 add_student.asp
3 Student_Data.asp(After Insert)
5. Student_update_form.asp
6 Student_update_select.asp(After Update)
8. Student_delete_select.asp(After Delete)