24) Write an ASP code to read emp_no, emp_name, address, salary from the database.


//save this file as form1.html at location C:\Inetpub\wwwroot\
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form method =POST action=”Emp.asp”>
<input type=”submit” value=”Submit” />
</body>
</html>
// Save this file as Emp.asp at location C:\Inetpub\wwwroot\
<% language=VBScript %>
<%
Dim adoCon
Dim rs
Dim sq
Dim uname1
uname1=request.form(“t1?)
Dim upass1
upass1=request.form(“t2?)
Set adocon=Server.createObject(“ADODB.Connection”)
adocon.Provider=”MicroSoft.Jet.OLEDB.4.0?
adoCon.Open “C:\Inetpub\wwwroot\emp.mdb”
Set rs=Server.CreateObject(“ADODB.recordset”)
rs.open “Select * from emp”,adocon
Response.Write(“<h1>Employee Detail </h1>”)
Response.Write(“<table border=1><tr><td>EMP No.</td><td>Emp Name</td><td>Emp ADD</td><td>Salary</td></tr>”)
while Not rs.EOF
Response.Write(“<tr>”)
Response.Write(“<td>”&rs.Fields(0)&”</td>”)
Response.Write(“<td>”&rs.Fields(1)&”</td>”)
Response.Write(“<td>”&rs.Fields(2)&”</td>”)
Response.Write(“<td>”&rs.Fields(3)&”</td>”)
Response.Write(“</tr>”)
rs.MoveNext
Wend
%>
Step1:- start internet explorer and type http://localhost
Step2:- then type http://localhost/form1.html in address bar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s