Download Win2Ka

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Database wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Microsoft Access wikipedia , lookup

Relational model wikipedia , lookup

Functional Database Model wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Team Foundation Server wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Object-relational impedance mismatch wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Transcript
Windows 2000/ XP Overview
Norman White
Stern School of Business
Windows 2000 as a Web Platform
• What are the issues one needs to address in
considering W2K/ XP as a web Platform?
• What is W2K?
– Several Variations
•
•
•
•
Professional
Server
Advanced Server
DataCenter Server
Professional
• Upgrade to NT Workstation
– Designed for single users, small workgroups
– More secure and reliable than 98, NT etc.
– Supposedly crashproof due to major system
redesigns
Win 2K Server
•
•
•
•
•
Entry level Server Version
Supports 5 connections
IIS Web Server included
Basic File and Print Sharing
Can support up to 4 Processors
Win 2K Advanced Server
• Supports multiple systems (up to 8
processors each)
• 25 users (more at $40/user)
• Semi fault tolerant
Win 2K Data Center Server
•
•
•
•
Mainframe competition
32 processor support
System clustering support
Can Scale up (more processors) or out
(more Clusters)
• Designed for Mission critical environments
Problems fixed/addressed under
Win 2K
• Plug and play supports most (not all ) new
devices
• Designed to be crash proof (claims are
99.999% up time for Win2K Data Center)
– Windows File protection keeps new
applications from replacing DLLs with older or
incompatible versions
– Reboots no longer necessary to install software
– Terminal Services Access Client through IE
What about Win2K as a Web
Platform?
• IIS - Top Rated Web server, easier to administer
than Unix servers
• Supports most common add-ons like Php, PERL,
JRE etc.
• In addition supports ASP, Active Server Pages
• Also supports Front Page Extensions which allow
Front Page users advanced development tools,
including Visual Studio.
Win2K /IIS
• IIS also includes a built-in Indexing Server
for searching content
• “Virtual sites” allow you make any folder
on the system appear as a /directory under
the root directory.
• ODBC support of Win2K allows easy
access from ASP to other databases, either
local or remote
IIS/ASP Integration with Office
• IIS and Office are tightly integrated in
Office 2000
• Office applications can be used to directly
generate Web applications, including Data
Base applications
• Integration makes it a great development
environment for prototyping
• But first, what is ASP?
Active Server Pages
• Concept is to have web pages that
dynamically change (at the server)
depending on external events (data, time,
client, form inout etc).
• ASP is Visual Basic Code embedded in the
web page (like Javascript) and interpreted at
the server before the page is delivered.
ASP Processing
• Unlike CGI processing and some other
approaches, the ASP processor is part of the
IIS web server (just as javascript is part of
the browser).
• This means that the OS does not have to
start up another application on every page.
• If the page has an ASP extension, the web
server will look for embedded ASP code.
ASP coding
• Whenever the web server finds an ASP
reference, it turns control over to ASP. The
ASP processor executes the instructions and
the returns control to the web server. Since
the ASP processor is part of the web server,
it can do things like generate HTML
directly.
• But it can also do almost anything you can
do in VB, including data base access.
More ASP
Forms
• Since ASP is part of the WEB server access to
form information is much easier than most other
approaches.
• Var = request.QueryString(“fieldname”);
– will place contents of field “fieldname” in Variable
“Var”
– (nicer than Unix shell huh?)
• Var = Request.Form(“fieldname”) for POST
ASP and Office
• Even better is the ability of Office to generate
working ASP applications
• Just click on “save as” and scroll down to the
Active Server Pages option
– Office will generate a set of ASP files that implements
the application on the WEB using ASP.
• Then move application to the web server and run
(maybe…)
ASP and Databases
• ASP accesses data bases using ODBC
(Open Data Base Connectivity ) now called
ADO (ActiveX Data Objects) and MDAC
• The name keeps changing, but the concept
is the same
– Application Opens a data base connection to a
local data object (which can point to remote
data)
– It then manipulates the data base
ODBC Naming
• As long as the ODBC name is the same on the
system you develop app and the web server,
everything should run on the web server (or else
you need to change the name)
• To add an ODBC data source to a system,
• Click on Start, Settings, Control Panel, ODBC
Data Sources (32 bit)
• Give the Data source a name, and then pick the
database system, the server and the userid and
password
Sample ASP file
• <%@ Language=VBScript %>
•
<html>
•
<head>
•
<title>Example 1</title>
•
</head>
•
<body>
•
<%
•
FirstVar = "Hello world!"
•
%>
•
<%=FirstVar%>
•
</body>
•
</html>
Looping in ASP
•
•
•
•
•
•
•
•
•
•
•
•
•
•
<%@ Language=VBScript %>
<html>
<head>
<title>Example 2</title>
</head>
<body>
<%
FirstVar = "Hello world!"
%>
<%FOR i=1 TO 10%>
<%=FirstVar%>
<%NEXT%>
</body>
</html>
Functions in ASP
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
<%@ Language=VBScript %>
<html>
<head>
<title>Example 3</title>
</head>
<body>
<%
FirstVar = "Hello world!"
%>
The time is: <%=time%> <BR>
<%FOR i=1 TO 10%>
<%=FirstVar%>
<%NEXT%>
</body>
</html>
Conditional Execution in ASP
•
•
•
•
•
•
•
•
•
•
•
•
•
%@ Language=VBScript %>
<html>
<head>
<title>Example 4</title>
</head>
<body>
<%IF Hour(time)>18 OR Hour(time)<4 THEN%>
Good Night Everyone.
<%ELSE%>
Good Morning Everyone.
<%END IF%>
</body>
</html>
Sample Form
(from Microsoft ASP Tutorial)
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
<html>
<head>
<title>Button Form</title>
</head>
<body>
<FORM NAME="Button Example" METHOD="POST" ACTION="tutorial/button.htm">
Computer Programming Experience:
<P>
<INPUT TYPE="button" NAME="choice" VALUE="Less than 1">Less than 1 year.<BR>
<INPUT TYPE="button" NAME="choice" VALUE="1 to 5">1-5 years.<BR>
<INPUT TYPE="button" NAME="choice" VALUE="More than 5">More than 5 years.
</P>
<P><INPUT TYPE="reset" VALUE="Clear Form">
<INPUT TYPE="submit" VALUE="Submit">
</P>
</form>
</body>
</html>
Guestbook Application
• Need to
– Create Database using Access
• I.e. create Table and fields
– Move Data Base to web server or create
database in c:\inetpub\wwwroot\Tutorial\
• (Default web server root)
– Create ODBC DSN for Database
– Create ASP application (guestbook.asp)
Guest Data Base fields
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Field Name
Data Type and General Properties
ID
AutoNumber, Field Size=Long Integer, New Values=Increment,
Indexed=Yes(No Duplicates)
TB1
Text, Field Size=255, Required=No, Allow Zero Length=Yes,
Indexed=No
TB2
Text, Field Size=255, Required=No, Allow Zero Length=Yes,
Indexed=No
TB3
Text, Field Size=255, Required=No, Allow Zero Length=Yes,
Indexed=No
TB4
Text, Field Size=255, Required=No, Allow Zero Length=Yes,
Indexed=No
MB1
Memo, Required=No, Allow Zero Length=Yes
Creating ODBC Data Source
•
1.In the ODBC Data Source Administrator, select the ODBC icon.
•
2.Select File DSN.
•
3.Select Add, select Microsoft Access Driver, and click Next.
•
4.Type in a descriptive name for your file DSN (Guestbook) and click Next.
•
5.Click Finish, click Select, specify the location of the database file, and
select OK.
•
6.Click OK twice. After you specify the location of the database file, the
ODBC Data Source Administrator creates a file DSN for it.
The Application Logic
Guestbook.asp
• See if “Message” field (hidden) is True
– If true, retrieve field values and insert new entry into
the database table
• Message not True
– If message is not true, generate the form
– with a hidden field “message” = TRUE
– and have the action statement run Guestbook.asp (this
asp file
• Note, only one file
– It either processes the input, or generates the form for
the input.
Guestbook.ASP file
(put in c:\inetpub\wwwroot\Tutorial)
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
<% @Language=VBScript %>
<html dir=ltr>
<head>
<TITLE>Guest Book</TITLE>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
IF request.form ("Message")="True" THEN
strTB1=request.form("To")
strTB2=request.form("EMailAdd")
strTB3=request.form("CC")
strTB4=request.form("Subject")
strMB1=request.form("Memo")
IF strMB1 = "" THEN
iLenMB1=255
ELSE
iLenMB1 = Len(strMB1)
END IF
Create the Database connection
• ‘Connects to the Access driver and Access database in the Inetpub
• ‘directory where the database is saved
• strProvider = "Driver={Microsoft Access Driver (*.mdb)};
DBQ=C:\Inetpub\Wwwroot\Tutorial\guestbook.mdb;"
• ‘Creates an instance of an Active Server component
• set objConn = server.createobject("ADODB.Connection")
• ‘Opens the connection to the data store
• objConn.Open strProvider
• ‘Instantiate Command object and use ActiveConnection property to
• ‘attach connection to Command object
• set cm = Server.CreateObject("ADODB.Command")
• cm.ActiveConnection = objConn
Create an SQL Query
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
‘Define SQL query
cm.CommandText ="INSERT INTO Guestbook (TB1,TB2,TB3,TB4,MB1) VALUES
(?,?,?,?,?)"
‘Define query parameter configuration information for guestbook fields
set objparam=cm.createparameter(, 200, , 255, strTB1)
cm.parameters.append objparam
set objparam=cm.createparameter(, 200, , 255, strTB2)
cm.parameters.append objparam
set objparam=cm.createparameter(, 200, , 255, strTB3)
cm.parameters.append objparam
set objparam=cm.createparameter(, 200, , 255, strTB4)
cm.parameters.append objparam
set objparam=cm.createparameter(, 201, , iLenMB1, strMB1)
cm.parameters.append objparam
cm.execute
response.write("Thank you!")
Handle New Entries
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
ELSE%>
<h1>Guestbook</h1>
<!--Post information to Guestbook form -->
<form name=guestbook.asp action="guestbook.asp" method="POST">
<p>To</p>
<p><input type="Text" name="To"></p>
<p>Email Address</p>
<p><input type="Text" name="EmailAdd"></p>
<p> CC</p>
<p><input type="Text" name="CC"></p>
<p>Subject</p>
<p><input type="Text" name="Subject"></p>
<p>Message</p>
<p><textarea name="Memo" rows=6 cols=70></textarea></p>
<input type="HIDDEN" name="Message" value="True">
<input type="submit" value="Submit information">
</form>
<%End if%>
</body>
</html>
So, How hard is that?
• Not too bad, but how does someone look at
the guestbook?
• Need another ASP file to view entries
• Nice to allow users to sort entries...
Viewing Program
•
•
•
•
•
•
•
•
•
•
•
•
•
<% @Language=VBScript %>
<html dir=ltr>
<head>
<title>View Guest Book</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
‘This section makes it possible for visitors to sort the data in the columns in
ascending order.
if request.form("sort")<> "" THEN
StrSort=request.form("sort")
ELSE
StrSort="TB1 ASC"
END IF
Connect to Guestbook
and create query
•
•
•
•
•
•
•
•
•
•
•
•
•
strQuery="SELECT * FROM Guestbook ORDER BY " &StrSort
‘Database path statement describing the driver to use and the path to the
desired database.
strProvider = "Driver=Microsoft Access Driver (*.mdb);
DBQ=C:\Inetpub\Wwwroot\Tutorial\guestbook.mdb;"
IF Request("ID") <> "" THEN
strIDNum=Request("ID")
‘Creates an instance of an Active server component
set objConn = server.createobject("ADODB.Connection")
‘Opens the connection to the data store
objConn.Open strProvider
‘Instantiate Command object and use ActiveConnection property to
‘attach connection to Command object
set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = objConn
• ‘Define SQL query
• cm.CommandText = "DELETE FROM Guestbook
WHERE ID = " &strIDNum
• cm.Execute
• END IF
• ‘Instantiate a Recordset object and open a recordset using
• ‘the Open method
• Set rst = Server.CreateObject("ADODB.recordset")
• rst.Open strQuery, strProvider
• %>
• <h1>Guest Book</h1>
• <form name=viewdb.asp action=viewdb.asp
method=post>
• <table border=1 cellspacing=3 cellpadding=3 rules=box>
• <%
• ON ERROR RESUME NEXT
• IF rst.EOF THEN
• Response.Write "There are no entries in the database."
• ELSE%>
• <tr>
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
<%
‘Deletes rows from the database, this cannot be undone
Response.Write "<td width=200><center>Delete Record</center></td>"
FOR i = 1 to rst.Fields.Count -1
Response.Write "<td width=200><input name=sort value=" & rst(i).Name & " type=submit></td>"
NEXT
WHILE NOT rst.EOF %>
<tr>
<%
Response.Write "<td align=left valign=top bgcolor=‘#ffffff’><a href=viewdb.asp?id=" & rst(0) &
">Delete</a></td>"
FOR i = 1 to rst.fields.count - 1
Response.Write "<td align=left valign=top bgcolor=‘#ffffff’>" & rst(i) &"</td>"
NEXT
rst.MoveNext
WEND
END IF
%>
</table>
</form>
</body>
</html>
What is happening?
What does the code do?
• Hint, What do you think the name of the asp
file is?
Conclusion
•
•
•
•
•
Win2K/XP fast development environment
Integrated with Office
BUT
Win2K still not a mature platform
Needs
– Something like a standard shell language
– Batch queues with priorities
– Priority for different applications etc.
• Excellent system for small – medium businesses.
• Still problematical for very large sites, but moving
fast.
Solution
DOT NET…..