Tài liệu Module 11: Accessing Data from the Outlook 2000 Client - Pdf 90

Contents
Overview 1
Introduction to Data Access in
Outlook 2000 Solutions 2
Using Office Web Components 4
Using ADO 12
Retrieving Data from an ADO Data
Source 17
Updating Data in an ADO Data Source 28
Accessing Exchange Server Information 37
Lab A: Searching and Retrieving
Information in the Exchange Server
Directory by Using ADSI 54
Review 57

Module 11: Accessing
Data from the
Outlook 2000 Client Information in this document is subject to change without notice. The names of companies,
products, people, characters, and/or data mentioned herein are fictitious and are in no way intended
to represent any real individual, company, product, or event, unless otherwise noted. Complying
with all applicable copyright laws is the responsibility of the user. No part of this document may
be reproduced or transmitted in any form or by any means, electronic or mechanical, for any

Editing Manager: Lynette Skinner
Editor: Jennifer Kerns (S&T Onsite)
Copy Editor: Shari G. Smith (R & S Consulting)
Online Program Manager: Arlo Emerson (Aditi)
Production Support: Irene Barnett (Barnett Communications)
Manufacturing Manager: Bo Galford
Manufacturing Support: Mimi Dukes (S&T Onsite)
Development Services: Kimber Dodge
Lead Product Manager: Mary Larson
Group Product Manager: Robert Stewart Module 11: Accessing Data from the Outlook 2000 Client iii Instructor Notes Module 11: Accessing Data from the
Outlook 2000 Client
This module describes how to access data from the Microsoft
®
Outlook
®
2000
client.
At the end of this module, students will be able to access data in a Microsoft
SQL Server

database by using Microsoft Office Web Components and
Microsoft ActiveX
®
Data Objects (ADO). They will also be able to access data


Lab:
45 Minutes
iv Module 11: Accessing Data from the Outlook 2000 Client Module Strategy
Use the following strategy to present this module:

Introduction to Data Access in Outlook 2000 Solutions
Describe the different ways that SQL Server data and Exchange directory
information can be accessed from the Outlook 2000 client.

Using Office Web Components
Define the Office Web components. Show how to create a Web page that
uses the Microsoft Excel PivotTable
®
List control and Microsoft Access
data access pages.

Using ADO
Provide an overview of OLE DB and describe its architecture. Then, explain
where ADO fits in this architecture. Provide a high-level discussion of the
main objects in the ADO object model. Define an ADO recordset and
describe how it is used.

Retrieving Data from an ADO Data Source
Describe the steps required to connect to a data source and return a
Recordset object. Once students have learned how to return a recordset,
show some ways that they can work with it. Show how to reference fields in

Using ADO

Retrieving Data from an ADO Data Source

Updating Data in an ADO Data Source

Accessing Exchange Server InformationAt the end of this module, you will be able to:

Describe the different ways that data can be accessed from the Microsoft
®

Outlook
®
2000 client.

Add a Microsoft Office Web component that connects to an external data
source to a Web page.

Define the relationship between Microsoft ActiveX
®
Data Objects (ADO)
and OLE DB.

Use ADO to connect to a data source, such as a Microsoft SQL Server


database, and retrieve data from that data source.

Using the Exchange Server Directory from Outlook 2000

Outlook object model

CDO

ADSIData from many different data sources, such as a Microsoft Access database, a
SQL Server database, an Oracle database, a mainframe database, or an
Exchange Server directory and information store, can be incorporated into your
Outlook 2000 solution through client-side data access.
Using SQL Server Data from Outlook 2000
Two ways you can incorporate SQL Server data into your Outlook 2000
solution include:

Office Web Components and Data Access Pages. Microsoft Office Web
components are Component Object Model (COM) controls that you can use
to publish interactive spreadsheets, charts, Microsoft PivotTable
®
lists, and
databases for the Web. Data access pages are interactive Web pages that
maintain a live link to a host Access or SQL Server database. With this live
link, users can view, edit, and manipulate data within a browser window.
These components can be placed in a folder home page or an Outlook 2000
form to provide quick access to SQL Server data.

Microsoft Visual Basic
®


CDO. The CDO Library is an interface to MAPI that provides an easy
method for gaining access to the directory information stored within an
Exchange Server Global Address List (GAL).

ADSI. ADSI is a set of specifications of COM objects and interfaces that
you can use to manipulate Exchange Server directory services and other
directory services. You can use the ADSI objects to perform common
administrative operations, such as adding new users or managing a print
queue.

4 Module 11: Accessing Data from the Outlook 2000 Client 



Using Office Web Components

Introduction to Office Web Components

Publishing an Interactive Web Page from Excel

Using Data Access Pages

Using the Data Source ControlThe Office Web components are COM controls that you can use to publish

Spreadsheet, PivotTable List, Data Source, and ChartOffice Web components enable you to incorporate spreadsheets, PivotTable
lists, charts, and data access pages into a solution in a number of different ways.
Using Office Web Components in a Solution
You can use the Web components in your Outlook 2000 solution in the
following ways:

Create a worksheet, PivotTable, or chart in Excel, and then save your work
as an interactive folder home page.

Create a data access page in Access and save it as an interactive folder home
page.

Add a reference to the Microsoft Office Web Components Object Library to
your custom application by using any development environment that
supports COM; then use the components as you would any other COM
object through automation.

Use the Office Web components in Active Server Pages (ASP), and then
generate static Hypertext Markup Language (HTML) or interactive Web
pages for display on the Internet or intranet client.

With Web components, users can interact with a Web page from within a
browser, while using many of the features that are found in the full version of
the application.
Slide Objective
To describe the different
ways that Office Web

managing the sorting, filtering, and updating of records.
Chart Graphically displays information from a spreadsheet, a
PivotTable, or the data source component. A chart updates
instantly in response to user interaction with the other
components. Users must have Microsoft Internet Explorer version 4.01 (or later) and
an Office 2000 license to browse a Web page interactively by using Office Web
components.

Note
Module 11: Accessing Data from the Outlook 2000 Client 7 Publishing an Interactive Web Page from Excel
C:\My Documents\Page.htm – Microsoft Internet Explorer provided by ITG
C:\My Documents\Page.htm – Microsoft Internet Explorer provided by ITG
F
ile Edit View GoFavorites Help
Forward
Forward Stop Refresh Home Search Favorites History PrintMail
Links
Address C:\My Documents\Page.htm
CategoryName
Back
Back
Go
PivotTable2
EmployeeID

1. Activate the worksheet that contains the worksheet, PivotTable, or chart.
2. On the File menu, click Save as Web Page.
3. Click Publish.
4. In the Choose list, select the type of data that you want to publish. In the list
box, click the item that you want.
5. Select the Add interactivity with check box, and then choose the type of
functionality (Spreadsheet, PivotTable, or Chart).
6. To add a title to the published section, click Change, enter the title that you
want, and then click OK.
7. Click the Browse button, and locate the drive, folder, Web folder, Web
server, or File Transfer Protocol (FTP) location where you want to publish
your Web page.
8. Click Publish.

Slide Objective
To show a Web page that
uses Office Web
components.
Lead-in
You create a Web page that
uses Office Web
components by first creating
the spreadsheet,
PivotTable, or chart in
Excel.
8 Module 11: Accessing Data from the Outlook 2000 Client Using Data Access Pages
Category Entry Page – Microsoft Internet Explorer provided by ITG

page that is based on a SQL
Server database.
Lead-in
To maintain a live link to an
Access or SQL Server
database, you must use
data access pages.
Module 11: Accessing Data from the Outlook 2000 Client 9 Creating a Data Entry Page
The Page Wizard makes creating a data entry page simple. You specify the
table or query that you want to use with the form, and the wizard creates a data
input form for you.
To create a data entry page by using the Page Wizard:
1. Open your database application.
To open an existing SQL Server database in Access:
a. On the File menu, click New.
b. On the Project tab, click Project (Existing Database), and then click
OK.
c. In the File New Database dialog box, enter a name for the database, and
then click Create.
d. In the Data Link Properties dialog box, provide connection
information for the SQL Server database.
e. To make the data access page read-only, click the Advanced tab of the
Data Link Properties dialog box, specify access permissions, and then
click OK.
The default value for access permissions is Share Deny None, which
means that all users can read and write to the database.
2. On the Objects bar, click Pages.


Construct hierarchical Recordset objectsYou can use the Data Source control directly, or indirectly through the use of
the other Office Web components.
Function of the Data Source Control
The Data Source control is the reporting engine behind data access pages,
PivotTable List controls, and data-bound Chart controls. The Data Source
control has no visual representation at run time. It is designed to manage the
connection to the underlying data source and deliver records to be displayed by
other controls on a Web page.
The Data Source control relies on ADO for connections to relational data
sources such as Access, SQL Server, or Oracle databases. Although the Data
Source control can provide data to the PivotTable List control, the Data Source
control cannot be bound to multidimensional data sources; transformations of
relational data to multidimensional data are managed by the PivotTable Service.
Slide Objective
To describe the purpose of
the Data Source control and
how it is used.
Lead-in
The Data Source control is
used to perform several
tasks for data access pages,
the PivotTable List control,
and the Chart control.
Module 11: Accessing Data from the Outlook 2000 Client 11

Note
12 Module 11: Accessing Data from the Outlook 2000 Client 



Using ADO

Overview of OLE DB Technology

Using the ADO Object ModelADO technology is supported by a variety of Microsoft development platforms,
including Visual Basic, Visual Basic for Applications, Microsoft Visual Basic,
Scripting Edition (VBScript), Microsoft Visual C++
®
, Microsoft Visual
FoxPro
®
, and Microsoft Visual InterDev
®
.
ADO provides the programmatic interface between OLE DB data and your
applications. The ADO object model defines a group of objects that allow you
to connect your application to a data source, retrieve and manipulate data from
the data source, and disconnect from the data source when you finish using the

Mainframe
Data
Non
Relational
Data
ODBC
OLE DB ProviderADO provides the interface between Office 2000 applications and OLE DB
data. OLE DB is Microsoft’s strategic, system-level programming interface to
access data throughout an organization. Whereas Open Database Connectivity
(ODBC) is designed to allow access to relational data, OLE DB is an open
standard that is designed to allow access to all kinds of data.
Conceptually, OLE DB has three types of components: data providers, data
consumers, and service components. ADO handles the application-level
programming.
Data Providers
Data providers are applications (such as SQL Server or Exchange Server), or
operating system components (such as a file system) that include data that other
applications may need to access. These data providers supply the OLE DB
interfaces that data consumers or service components can access directly.
ODBC also has an OLE DB provider that makes ODBC data available to OLE
DB data consumers. The examples in this module use SQL Server as the data
provider.
Data Consumers
Data consumers are applications that use the data exposed by data providers.
ADO technology provides the programmatic interface for using OLE DB data.
Any application that uses ADO is an OLE DB data consumer. The examples in
this module are written by using VBScript, and assume that an Outlook 2000

do not support function pointers and other C++ call mechanisms. ADO provides
the following advantages to programmers:

Ease of use. The data-access task analogous to “Hello World” requires only
three lines of code.

Programming language neutral. ADO can be used from languages such as
Microsoft Visual Basic, Java, C++, VBScript, and Microsoft JScript
®
.

Provider neutral. ADO can access data from any OLE DB source. In
addition, ADO adapts gracefully to support less functional OLE DB
providers.

No loss of OLE DB functionality. ADO allows C++ programmers access to
the underlying OLE DB interfaces.

Extensible. ADO can dynamically expose properties specific to a data
provider by means of collections of provider properties. In addition, it
provides type extensibility by allowing access to COM objects exposed as
column values (for example, rowset and stream).

Module 11: Accessing Data from the Outlook 2000 Client 15 Using the ADO Object Model
Error
(Optional)
Field

Main Components of the ADO Object Model
The three main components of the ADO object model are the Connection
object, the Command object, and the Recordset object.
Connection Object
The Connection object is the highest-level object in the ADO object model. It
is used to make a connection between the application and a data source, such as
an Access database or a SQL Server database.
Command Object
A Command object is a definition of a specific command that you intend to
execute against a data source, for example, a SQL Server statement or a stored
SQL Server procedure.
Slide Objective
To show the ADO object
model.
Lead-in
The simple ADO object
hierarchy makes it relatively
straightforward to connect to
a data source and use its
data.
16 Module 11: Accessing Data from the Outlook 2000 Client Recordset Object
By using the Recordset object, you can access the records that a database table
or a SQL Server query return. With the Recordset object, you can navigate the
returned records, modify existing records, add new records, or delete specific
records.
Setting a Reference to ADO
Before you can use the ADO object model in your Visual Basic for

with its data.
Slide Objective
To outline this topic.
Lead-in
To retrieve data from a data
source you must complete
two tasks: establish a
connection to the data
source and then create a
new recordset.
18 Module 11: Accessing Data from the Outlook 2000 Client Establishing a Connection

Declaring a Connection Object

Setting Connection Properties

Opening the Connection
Dim cnNorthwind
Set cnNorthwind = _
Item.Application.CreateObject("ADODB.Connection")
Dim cnNorthwind
Set cnNorthwind = _
Item.Application.CreateObject("ADODB.Connection")
With cnNorthwind
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;Password=;" & _
"Data Source=MyServer;" & _

establishing a connection to
a data source.
Lead-in
Establishing a connection to
that data source is the first
step in using ADO.
Module 11: Accessing Data from the Outlook 2000 Client 19 Setting Connection Properties
The Connection object contains information about connections to OLE DB
service providers. Use the Connection object properties to specify the type of
data source and other information that the OLE DB provider needs to connect
to the data source.
Property Description

Provider Indicates the name of the OLE DB provider for the connection.
The OLE DB provider for SQL Server is specified as
SQLOLEDB.
The OLE DB provider for ADSI is specified as ADsDSOObject.
The OLE DB provider for Microsoft Jet 4.0 (for Access
databases) is specified as Microsoft.Jet.OLEDB.4.0.
ConnectionString Contains the information that is used to establish a connection to
a data source.
SQL Server requires this property but Access does not. This
information is typically passed to Access when the connection is
opened, rather than by using the ConnectionString property.

The following example sets the Provider and ConnectionString properties for
the cnNorthwind connection. This code establishes a connection to the

Set rsCustomers = _
Item.Application.CreateObject("ADODB.Recordset")
With rsCustomers
.CursorType = adOpenStatic
.Open "Customers", cnNorthwind
End With
Dim rsCustomers
Set rsCustomers = _
Item.Application.CreateObject("ADODB.Recordset")
With rsCustomers
.CursorType = adOpenStatic
.Open "Customers", cnNorthwind
End With
' Close objects and clean up
rsCustomers.Close
cnNorthwind.Close
Set rsCustomers = Nothing
Set cnNorthwind = Nothing
' Close objects and clean up
rsCustomers.Close
cnNorthwind.Close
Set rsCustomers = Nothing
Set cnNorthwind = NothingWhen you use the Recordset object, your application can access data returned
from a table or a SQL Server query. By using the Recordset object, you can
navigate the records that have been returned, edit their values, add records, or
delete records.
Creating a Recordset Object

objects that are based on
that single connection.
Module 11: Accessing Data from the Outlook 2000 Client 21 The following table lists and describes the properties of the Recordset object
that are commonly used to create a recordset.
Property Description

CursorType Sets the cursor type. The default is adOpenForwardOnly. For more
information on CursorType, search for “CursorType property
(ADO)” in Visual Basic Help.
LockType Sets the type of record locking. The default constant is
adLockReadOnly. For more information on LockType, search for
“LockType property (ADO)” in Visual Basic Help. For a complete listing of Recordset object properties, search for
“Recordset object (ADO)” in Visual Basic Help.

Opening a Recordset Object
You create a new recordset from an existing Connection object. Use the Open
method of the Recordset object to open the recordset. The Open method opens
a recordset that is based on a particular table or on the result of a SQL Server
statement.
The following example creates a Recordset object, sets the cursor type to static,
and then opens the Customers table in the Northwind database.
Dim rsCustomers
Set rsCustomers = _
Item.Application.CreateObject("ADODB.Recordset")


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status