20)Write an ASP code to accept doc_no, doc_name, city, hosp_name from user, stores in database and then display all doctor details on the screen.


Doctor.html
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form method =POST action=”Insert.asp”>
Doctor Number :-<input type=”text” name=”t1? /><br>
Doctor name<input type=”text” name=”t2? /><br>
Doctor City<input type=”text” name=”t3? /><br>
Doctor Hospital<input type=”text” name=”t4? /><br>
<input type=”submit” value=”Submit” />
</body>
</html>

Insert.asp
<%
Dim adoCon
Dim rs
Dim sq
Dim dno
Dim dm
Dim dcity
Dim dhos
dno=request.form(“t1?)
dm=request.form(“t2?)
dcity=request.form(“t3?)
dhos=request.form(“t4?)
Set adocon=Server.createObject(“ADODB.Connection”)
adocon.Provider=”MicroSoft.Jet.OLEDB.4.0?
adoCon.Open “C:\Inetpub\wwwroot\doctor.mdb”
Set rs=Server.CreateObject(“ADODB.recordset”)
sq=”INSERT INTO doctor(doc_no,dm,dcity,dhos)values(“& dno & “,’” & dm & “‘,’” & dcity & “‘,’” & dhos & “‘ )”
adocon.Execute sq
Response.Write(“record inserted successfully”)
Set rs=Server.CreateObject(“ADODB.recordset”)
rs.open “Select * from Doctor”,adocon
Response.Write(“<h1>Doctor 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
%>

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