At present, management information systems have shifted from the traditional client/server (C/S) model to the browser/server (B/S) model. Especially after Microsoft launched its new product ASP language, this change has become even more rapid. The core of the management information system is to perform operations on the database, including adding, modifying and querying. The ADO database interface control provided by ASP allows programmers to no longer need to write complex CGI programs, but only needs to use a few simple statements. The above operations can be achieved. There are currently many program examples introducing the use of ASP to develop network databases, but most of them use ACCESS as the underlying database. Compared with ACCESS, the SQL SERVER database system is much more complex, so more work needs to be done in program development. Based on my own experience in developing management information systems, the author will give an example here to communicate with interested friends.
---- 1. System environment
----PII 350, Ram 64M, WINNT Server 4.0,
Service Pack 4, IIS 4.0, SQL Server 7.0.
---- 2. System functions
---- By using the IE browser, the "Office Files" data table records can be added and queried online.
---- 3. Function realization
---- (1) Data table settings
---- ①Start Enterprise Manager of SQL Server7.0,
Add a new subdirectory test under the Databases directory;
---- ② Add a new table under test, named office file, field settings: file name, char, 100, allowed to be empty; file content, char, 4000, allowed to be empty.
---- ③Add a user in SQL Server named hxl, password is 123, login mode is SQL login, and its default login database is set to test;
---- ④Add a new user under the test database, named hxl, and set its role to Dbowner.
---- (2)ODBC link
---- ① In the control panel, open the ODBC data source, select the system DSN item, and click Add;
---- ②Select the SQL Server data source and name it test;
---- ③Select the login mode as SQL Server authentication, the login flag as hxl, and the password as 123;
---- ④ Set the default database height to test, then test the database link and connect it.
---- (3)Program files
---- In order to realize the system functions, three program files are edited here, namely index.html, add.asp and query.asp. The specific contents are as follows:
---- ①index.html: System home page, including two options, one is to append records, and the other is to query. The user can click one of the two to enter the corresponding operation process. The following is the source program:
<html>
<head>
< meta http-equiv=Content-Language
content=zh-cn >
< meta http-equiv=Content-Type
content=text/html; charset=gb2312 >
< meta name=GENERATOR content=Microsoft
FrontPage 4.0 >
< meta name=ProgId content=FrontPage
.Editor.Document >
<title>Sample program</title>
</ /head >
<body>
<p align=center>
< font size=5 color=#008000 >
Welcome to SQL using ASP language
SERVER database operation example< /font >< /P >
< p align=center > < /P >
< p align=center >< a href=add.asp >
Append records< /a >< /p >
< p align=center >< a href=query.asp >
Query< /a >< /p >
< /body >
< /html >
---- ②add.asp: Implement the addition of records in the "Office Files" data table. The page contains a single-line text box
(Txtbiaoti) and a scrolling text box (Txtneirong), used to enter the file title and file content respectively. In addition, there should be two buttons on the page, OK (Cmdok) and Rewrite (Cmdcancel). Click OK to complete the record appending, and click Rewrite to re-enter the content. The following is the source program:
<html>
<head>
< meta http-equiv=Content-Type
content=text/html; charset=gb2312 >
< meta name=GENERATOR content=
Microsoft FrontPage 4.0 >
< meta name=ProgId content=
FrontPage.Editor.Document >
<title>Append a new record</title>
</ /head >
<body>
< % if request.form(cmdok)=OK then % >
<%
setdbconnection=server.createobject
(adodb.connection) dbconnection.opentest,hxl,123
sqlquery=insert office file
(file name, file content)
values ('request.form(Txtbiaoti)','
request.form(Txtneirong)')
set recadd=dbconnection.execute(sqlquery) % >
< % else % >
< p align=center >Append record< /p >
< form method=POST action= >
< p >File name: < input type=text
name=Txtbiaoti size=20 >< /p >
<p>File content:</p>
<p>
< textarea rows=3
name=Txtneirong cols=60 >< /textarea >
< /p >
< p align=center >< input type=submit
value=OK name=Cmdok >
< input type=reset value=rewrite
name=Cmdcancel>
</ /p >< /form >
< % end if% >
< /body >
< /html >
---- ③query.asp: Realizes the query of "Office Documents" data table records. The program only implements the query of file names in "Office Documents", and the query results are listed in a form (Table). The following is the source program:
<html>
<head>
< meta http-equiv=Content-Type
content=text/html;charset=gb2312 >
< meta name=GENERATOR content=Microsoft
FrontPage 4.0 >
< meta name=ProgId content=
FrontPage.Editor.Document >
<title>Retrieve files</title>
</ /head >
< body bgcolor=#ffffdd >
<%
setdbconnection=server.createobject
(adodb.connection)
dbconnection.open test,hxl,123
sqlquery=SELECT file name FROM office file
set resultlist=dbconnection.execute(sqlquery)
%>
<center>
< font color=red >< %=request(selectsource)% >
< /font >< font color=#008000 size=5 >< b >
The following documents are available for viewing< /b >< /font >
<hr size=5>
<table border=1>
<tr>
< td width=200 align=center > < b >
File name < /b > < /td >
< /tr >
< % do while not resultlist.eof % >
<tr>
< td valign=center width=200 >< %=resultlist
(file name)% >< /a >< /td >
< /tr >
<%
resultlist.movenext
loop
resultlist.close
%>
< /center >
< /TABLE >
< /body >
< /html >
---- 4. Summary
---- Use IE to open index.html or publish the file to the site and perform corresponding operations to append and query the "Office Files" data table records in the SQL Server database system. The system goal has been achieved.