Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting...
-
Upload
scot-blaze-briggs -
Category
Documents
-
view
217 -
download
0
Transcript of Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting...
Tutorial 10 by SamTutorial 10 by Sam ine1020 Introduction to Internet Engineeringine1020 Introduction to Internet Engineering 11
Database Database & Server-side & Server-side
ScriptingScripting
Tutorial 10Tutorial 10
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 2
Creating DatabaseCreating Database
►Microsoft Access ExampleMicrosoft Access Example Create a blank databaseCreate a blank database Create a table in databaseCreate a table in database
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 3
Creating DatabaseCreating Database
►Setting attributeSetting attribute
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 4
Creating DatabaseCreating Database
► Setting primary keySetting primary key
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 5
Query DatabaseQuery Database
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 6
Query Database - Design Query Database - Design View View
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 7
Query Database – Design Query Database – Design ViewView
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 8
Query Database – SQLQuery Database – SQL
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 9
Database AccessDatabase Access
►Microsoft Universal Data Access (UDA)Microsoft Universal Data Access (UDA) Easy to use programming interfaceEasy to use programming interface Access for relational & non-relational Access for relational & non-relational
databasedatabase Application or Browser
ADO
ODBC
OLE DB
Relational data sources
Non-relational data sources
Mainframe/legacy data
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 10
Database AccessDatabase Access
►OLE DB (Object Linking and Ebedding DB)OLE DB (Object Linking and Ebedding DB) Open specificationOpen specification Core architectureCore architecture
Application or Browser
ADO
ODBC
OLE DB
Relational data sources
Non-relational data sources
Mainframe/legacy data
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 11
Database AccessDatabase Access
►ODBC (Open Database Connectivity)ODBC (Open Database Connectivity) Access data from a variety of DBMS Access data from a variety of DBMS
through a single interfacethrough a single interfaceApplication or
BrowserADO
ODBC
OLE DB
Relational data sources
Non-relational data sources
Mainframe/legacy data
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 12
Database AccessDatabase Access
►ADO (ActiveX Data Objects)ADO (ActiveX Data Objects) Ease to use, high performance, low Ease to use, high performance, low
memory overheadmemory overheadApplication or
BrowserADO
ODBC
OLE DB
Relational data sources
Non-relational data sources
Mainframe/legacy data
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 13
Registering a DatabaseRegistering a Database► Specific instructions for Windows Specific instructions for Windows
98/2000/XP:98/2000/XP: double-click the double-click the ODBC Data SourcesODBC Data Sources (32 bit) (32 bit) icon in the icon in the
Windows Control PanelWindows Control Panel to display the to display the ODBC Data Source ODBC Data Source AdministratorAdministrator dialog. dialog. - Click the System DSN tab to
view a list of all systems DSNs.
- Select the name to the right of Microsoft Access Driver (*.mdb) from the list.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 14
Registering a DatabaseRegistering a Database Click Click Add…Add… to display the to display the Create New Data Create New Data
SourceSource dialog. Select dialog. Select Microsoft Access Microsoft Access DriverDriver (*.mdb) (*.mdb) and click and click FinishFinish to display the to display the ODBC Microsoft Access SetupODBC Microsoft Access Setup dialog. dialog.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 15
Registering a DatabaseRegistering a Database Enter the Enter the Data Source NameData Source Name and and DescriptionDescription
field. Click the field. Click the Select…Select… button to display the button to display the Select DatabaseSelect Database dialog. Select the database dialog. Select the database that you want. Click that you want. Click OKOK to close this dialog. to close this dialog.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 16
Registering a DatabaseRegistering a Database
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 17
Registering a DatabaseRegistering a Database
The Banking DSN is now listed. The Banking DSN is now listed.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 18
Active Server Pages (ASP)Active Server Pages (ASP)
► Server-side scriptingServer-side scripting ASP file contains HTML and scripting codeASP file contains HTML and scripting code VBScript de facto language for ASP scriptingVBScript de facto language for ASP scripting
►Other languages can be usedOther languages can be used JavaScriptJavaScript
.asp.asp file extension file extension Send dynamic Web contentSend dynamic Web content
►HTMLHTML►DHTMLDHTML►ActiveX controlsActiveX controls►Client-side scriptsClient-side scripts► Java appletsJava applets
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 19
Active Server Pages (ASP)Active Server Pages (ASP)► ASP requiresASP requires
Web serverWeb server►Personal Web Server (PWS) Personal Web Server (PWS) ► Internet Information Server (IIS) Internet Information Server (IIS)
► How ASP works ? How ASP works ? Client sends requestClient sends request
►Server receives request and directs it to ASPServer receives request and directs it to ASP►ASP processes, then returns result to clientASP processes, then returns result to client
Server processes ASP fileServer processes ASP file►Parsed (top to bottom) by ActiveX component Parsed (top to bottom) by ActiveX component asp.dllasp.dll
►Parsed each time requestedParsed each time requested►Web server must support ASP by providing Web server must support ASP by providing
component such as component such as asp.dllasp.dll
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 20
Active Server Pages (ASP)Active Server Pages (ASP)
► ASP has several built-in objectsASP has several built-in objects RequestRequest object object
►Access information passed by HTTP Access information passed by HTTP GETGET or or POSTPOST►Used to access cookiesUsed to access cookies
ResponseResponse object object►Sends information such as HTML or text to clientSends information such as HTML or text to client
ServerServer object object►Provides access to server methods and propertiesProvides access to server methods and properties►Provides method Provides method CreateObjectCreateObject
Used to instantiate other objectsUsed to instantiate other objects
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 21
Active Server Pages (ASP)Active Server Pages (ASP)
► Scripting delimitersScripting delimiters <%<% and and %>%> Indicate code is to be executed on server, Indicate code is to be executed on server,
not clientnot client
►@LANGUAGE@LANGUAGE Specify scripting language (default VBScript)Specify scripting language (default VBScript) <% @LANGUAGE = “VBScript” %><% @LANGUAGE = “VBScript” %>
► Each time page refreshed, server loads Each time page refreshed, server loads and interprets ASPand interprets ASP
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 22
ASP/ADOASP/ADO
Data.html
<HTML><HEAD><TITLE>Sample Database Query</TITLE></HEAD>
<BASEFONT FACE = "ARIAL,SANS-SERIF" SIZE = 2><FONT SIZE = +2>
<STRONG>Querying an ODBC database.</STRONG></FONT><BR>
<FORM METHOD = "POST" ACTION = "data.asp"><INPUT TYPE = "TEXT" NAME = "QUERY" SIZE = 40
VALUE = "SELECT * FROM Info"><BR><BR><INPUT TYPE = "SUBMIT" VALUE = "Send Query">
</FORM></BODY></HTML>
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 23
ASP/ADOASP/ADO
Data.asp<HTML><BODY>The result of querying an ODBC database <% query = Request( "QUERY" )%> <% ' Open a database connection Set connection = Server.CreateObject( "ADODB.Connection" ) connection.Open( "db2" ) ' Open a record set Set recorderset = Server.CreateObject( "ADODB.RecordSet" ) recorderset.ActiveConnection=connection recorderset.Source=query recorderset.Open%> <TABLE BORDER = "1" CELLPADDING = "5" CELLSPACING = "0">
<% ' Iterate through the record set and create a new row ' in the table for each record While Not recorderset.EOF %> <TR><TD><% =recorderset("District") %></TD> <TD><% =recorderset("ID") %></TD> <TD><% =recorderset("Name") %></TD> <TD><% =recorderset("TelNo") %></TD> </TR> <% recorderset.MoveNext() Wend ' Close the record set and the connection recorderset.Close() connection.close() %> </TABLE><BR><BR></BODY></HTML>
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 24
ASP / ADOASP / ADO
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 25
Dreamweaver MXDreamweaver MX►Database WindowDatabase Window
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 26
Dreamweaver MXDreamweaver MX► RecordsetRecordset
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 27
Dreamweaver MXDreamweaver MX► Server BehaviorsServer Behaviors
Repeat regionsRepeat regions Dynamic textDynamic text