Sunday 18 September 2011

STUDENT INFORMATION SYSTEM USING ASP


STUDENT INFORMATION SYSTEM USING ASP

AIM
       To Write ASP program to retrieve the student details from Microsoft IIS server
Step 1: Create a DSN
Follow the steps in the For a Database Program section of this article to create a DSN to the Microsoft Access Northwind.mdb sample database.
Create a Data Source Name
To connect to a database by using ASP pages, you must first create a Data Source Name (DSN) on the Web server for the type of database to which you want to connect. To do so, use one of the following methods.

For a Database Program
To create a DSN for a database program (such as Microsoft Access):
1. Log on to the Web server computer as administrator.
2. Click Start, point to Settings, and then click Control Panel.
3. Double-click Administrative Tools, and then double-click Data Sources (ODBC).
4. Click the System DSN tab, and then click Add.
5. Select the database driver that you want (for example, Microsoft Access Driver (*.mdb), and then click Finish.
6. In the Data Source Name box, type the name that you want to use when you refer to this DSN in your ASP code. For example, Northwind.
7. In the Description box, type an optional description for the DSN. For example, Northwind DSN.
8. Click Select.
9. In the Select Database dialog box, browse to and select the database that you want. For example, Northwind.mdb.

NOTE: If the database is not on the Web server, click Network, and then click Browse. Locate the shared network folder that contains the database, and then click OK. Click Finish, and then select the database that you want.
10. Click OK.
11. Click Advanced.
12. If you want to automatically provide login credentials to the database when you use this DSN, type them into the Login name and Password boxes. Click OK.
13. Click OK, and then click OK.

NOTE: By default, the Northwind.mdb file is located in the C:\Program Files\Microsoft Office\Office\Samples folder.
Step 2: Create an ASP Page
1. Start Notepad.
2. In Notepad, type the following code:
3. On the File menu, click Save As.
4. In the Save As dialog box, navigate to C:\Inetpub\wwwroot in the Save in list, select All Files in the Save as type list, type database.asp in the File name box, and then click Save.
5.    Quit Notepad.
Step 3: Test the ASP Page
1. Click Start, and then click Run.
2. In the Open box, type http://localhost/database.asp, and then click OK. A Web page that displays the NorthWind sample database customer list is displayed in the browser window.
PROGAM
Home.html :(C:\Inetpub\wwwroot\home.html)

<HTML>
<HEAD><TITLE>ASP Database Connection</TITLE></HEAD>
<BODY BGCOLOR=cyan>
<H1>Student Database Details</H1>
<form action="as3.asp" method="get">
enter reg no: <input type="text" name="regno">
<input type="submit" value="enter">
</form>
</body>
</html>

Asp3.asp(C:\Inetpub\wwwroot\asp3.asp)
<HTML>
<HEAD><TITLE>ASP Database Connection</TITLE></HEAD>
<BODY BGCOLOR=cyan>
<H1>Student Database Details</H1>
<%
dim regno,temp
regno=Request.QueryString("regno")
Dim Connect, selectSQL, RecSet
Set Connect = CreateObject ("ADODB.Connection")
Connect.Open "DSN=aspdb"
selectSQL = "SELECT * FROM student"
Set RecSet = Connect.Execute (selectSQL)
If NOT RecSet.EOF THEN
DO UNTIL RecSet.EOF
temp=RecSet("reg_no")
If temp = regno Then
Response.Write("Name     :")
Response.Write RecSet("student_name")&"<br>"
Response.Write("regNo     :")
Response.Write RecSet("reg_no")&"<br>"
Response.Write("dept      :")
Response.Write RecSet("dept")&"<br>"
Response.Write("semester no     :")
Response.Write RecSet("semester")&"<br>"
Response.Write("percentage      :")
Response.Write RecSet("percentage")
End If
RecSet.MoveNext
Loop
End If
RecSet.Close
Connect.Close
Set RecSet = Nothing
Set Connect = Nothing
%>
</BODY></HTML>
OUTPUT
C:\database3.mdb

0 comments:

Post a Comment