VB6
Distributed
Distributed Applications
They are
client/server applications that use a network in a multi-tier
architecture to distribute their presentation services,
business logic, and data services. These applications often
access many different data sources. The COM components
contained in these applications typically participate in
transactions, and they can be shared by multiple users and
multiple applications.
MOC Chapter 1: Microsoft’s Enterprise Development Strategy
This chapter discusses the
different types of client/server applications that can be
built using Microsoft technologies. It emphasizes the
important separation of services into different tiers (or
levels) when building solutions that are to be developed over
a distributed network such as the Internet.
-
Different services are
implemented in either the User (Presentation),
Business or Data services tiers. Although
this course primarily discusses 3-tiered applications, the
exam often uses the term "n-tiered" to
reflect the ever-growing focus on Internet-deployed
applications. It simply reinforces the fact that these
three main separations can be even further sub-divided
into other logical units. Essentially, the User, Business
and Data services layers are the main sub-divisions from
which others can be branched off.
-
Any interface that the user
interacts with (i.e.: database front end) is placed in the
User layer, all business rule processing (i.e.: credit
card limit checks, tax calculations, etc.) is done in the
Business layer and any services which provide data (i.e.:
SQL Server database) to the middle tier (and ultimately
the user) are placed in the data services layer. Remember
that business services are considered to be clients
of the data services layer which provides services
to it. The three services (User, Business and Data) are
collectively known as the Microsoft Application
Model.
The chapter continues to briefly discuss COM, its main
advantages and how it is implemented (how classes interact).
More on this later.
-
The main advantages of COM are
code reusability, cross-platform
interoperability, version control - and the fact
that testing COM components is much easier than
testing traditional applications that do not use COM.
Finally, this chapter also
discusses the Microsoft Solutions Framework (MSF)
Process Model. There are four stages in this
model: envisioning, planning, developing
and stabilizing. Once each step is complete, a "milestone"
is reached. There isn’t much emphasis on this material,
however, as it is specifically tested in core Exam 70-100 -
Analyzing Requirements and Defining Solution Architectures.
MOC Chapter 2: Building COM
DLL’s with Visual Basic
COM DLL’s are implemented in
the
Business Services layer. When using Microsoft
Transaction Server (MTS), COM components must be implemented
as DLL’s. This chapter covers the basics of Visual Basic DLL
class modules but it emphasizes several key points
-
When the DLL is compiled, each
class module in the DLL is assigned a unique class ID (CLSID).
A library identifier (LIBID) is also generated for
the DLL that describes all of the classes, their
properties and methods.
-
Version Compatibility options
include: No Compatibility, Project
Compatibility and Binary Compatibility. If you
want a component to remain compatible with previously
compiled versions of the DLL, choose Binary
Compatibility. Choosing this option also makes sure that
you will be warned if your new DLL has any features
that are incompatible with earlier versions. Choose No
Compatibility for new projects, Project Compatibility for
projects that are still in the testing stage and Binary
Compatibility to maintain compatibility with components
that have already been implemented and gone live.
-
To test an ActiveX DLL, open
the DLL project, add a new project and then choose
Standard EXE. A template for this new project will be
added to the Project Group window. Next, right-click on
the Standard EXE project and choose Set as Start Up.
Finally, add a reference to the ActiveX DLL project by
clicking on Project in the Visual Basic menu bar and then
choosing References. To test an ActiveX EXE
project, you must open a second (separate) instance of
Visual Basic because ActiveX EXE’s run out-of-process.
MOC Chapter 3: Introduction to Microsoft Transaction Server (MTS)
Part of the NT 4.0 Option
Pack, Microsoft Transaction Server (MTS) can be thought of
as the infrastructure that is responsible for the
management of transactions in a multi-user environment
(a component-based transactions processing
system). Because transactions management is its sole focus,
the application programmer need not worry about issues such as
security, data integrity and the proper handling of
transactions over the network. He or she can thereby
concentrate on programming the individual components that
interact with it.
MTS works on an
all-or-nothing principle and manages resources
in an effective way using just-in-time
activation and connection pooling.
Using these three methodologies, MTS is able to conserve
valuable resources such as memory, processing time and network
bandwidth. In addition, MTS also integrates the tight security
features of Windows NT.
Points to remember for the
exam
-
Once you have access to one
package (i.e.: you have passed the security check to
access its components), there are no subsequent security checks
for components within the same package. MTS does check
security, however, when you try to access components’
methods across different packages.
-
Resource Managers
manage
durable data. Examples of resource managers include
databases (SQL, Oracle, etc.), message queue systems like
MSMQ Server and transactional file systems.
-
MTS Explorer
is used to manage components and
packages on MTS. It allows you to create packages, add or
delete components from packages, distribute packages,
install and maintain packages and monitor transactions.
Package properties (such as identity and security) can
also be set from the MTS Explorer.
-
To create a new package
using MTS Explorer, first click on the Packages Installed
folder. From the Action menu, choose NEW and then PACKAGE.
You can alternatively right click on the Packages
Installed folder, click NEW and then choose PACKAGE as
well. When the Package Wizard shows up, choose Create an Empty
Package and enter a name for the new package. You
can also import pre-built packages (that were
created using the export function) by using the Install
pre-built packages option.
-
To add a component
(DLL) to a package, double-click the Packages Installed
folder and then double click on the package that you’d
like to add the component to. At this point, click on the Components
sub Folder, click New on the Action menu and then choose
Component. As an alternative to the Action menu, you can
also right-click the Components Folder, click New
and then select Component. The last step is to follow the
instructions in the dialog boxes, select Add Files
(choosing the components that you would like to add to the
package) and then click Finish.
-
Once a component (DLL) becomes
part of a package, MTS modifies the corresponding entries
for each class in the Windows registry so
that they can run under MTS: a LocalServer32 key
is added (containing the path to the MTS executable), a /p
parameter is added to the Mtx.exe path (which specifies
the identity of the package that contains the class) and
the
InProcServer32 key is cleared (empty value assigned)
as it is no longer needed.
-
Remember that a component
can only be included in one package on a
single computer and that a package’s components cannot
be split across computers. You can duplicate packages,
however, so that multiple copies of it and its components
reside on multiple (different) computers.
-
To export a package,
double-click the Packages Installed folder, select the
package that you’d like to export and then choose
Export from the Action menu. As an alternative to
the Action menu, you can also right-click on the package
and select Export. Follow the dialog box instructions
which follow.
-
When a package is exported, a
Clients folder is created in the directory
where the package file is exported to. You will find a
client application executable in the that
same folder which will allow you to configure a client to
remotely use the MTS components in the package. To install
the executable, simply run it on the client computer. Do
not ever run this client application
executable file on the server!
MOC Chapter 4: Using MTS Transaction Services
When MTS manages transactions
(changes in data from one state to another), it
makes sure that the four ACID principles are always applied:
atomicity, consistency, isolation and
durability. These properties ensure that transactions
are either properly committed or rolled
back from the time that the transaction begins to the
time that it ends (either normally or otherwise).
-
When an MTS object is accessed
and created (by the client or another object), it must be
aware of its context. MTS creates a
context object for each MTS object instance.
The context object informs the MTS object of its
environment and that it is participating in a transaction.
Transactions must be initially stateless to
participate in transactions.
-
MTS also uses the context
object to track the success or failure of transactions. If
an object completes its work successfully, it is noted in
the context object. Likewise, if an object fails to
complete its work, the failure is noted in the context
object. When all context objects report successes, then
MTS
commits the transaction – otherwise if
there is even one failure being reported by an object (in
its respective context object), then MTS rolls
back the entire transaction, undoing any changes
that were made.
-
To determine how a class
participates in transactions, set its Transaction
attribute. This can either be set from within MTS (by
right-clicking the class name in MTS Explorer, choosing
properties and then clicking on the Transactions tab) –
or by using the properties window (for the particular
class module) in Visual Basic.
-
Context information about each
object is stored in the ObjectContext
object. This object is responsible for the tracking of
individual MTS objects’ work successes or failures as
well as security information. When a object completes its
work successfully, the SetComplete method
of the ObjectContext object should be called. If, on the
other hand, an object’s work fails to complete, the SetAbort
method of the ObjectContext object should be called.
SetComplete informs the object context that it can
commit transaction updates – and release the state
of the object (and any resources that it was using).
SetAbort, on the other hand, informs the object
context that any transaction updates for that object (and
any other objects within the same transaction) must be
rolled back to their original state – even if the other
objects completed successfully and called
SetComplete. Remember: all or nothing.
-
There are three ways to create
objects in VB: using the New keyword, using
CreateObject and calling the
CreateInstance method of the ObjectContext
object. The first two methods will create MTS objects –
but unlike CreateInstance, they will not inherit
the object’s context information. Unless CreateInstance
is used, the object will not be able to participate in any
transactions and will not have access to security
information.
-
In order to ensure that the
application remains scalable (performance
isn’t affected as application use increases), you should
try to avoid maintaining state as much as possible.
State is object data that is maintained over
several method calls. State consumes resources such as
memory, disk space and database connections. MTS requires
stateless objects. Remember to obtain resources late and
to release them as early as possible.
-
Other services provided by MTS
include Trace Messages, the Transactions
List and Transaction Statistics. The
Trace Messages window lists any messages issued by
Microsoft Distributed Transaction Coordinator (DTC), the
Transaction List window shows any transactions in
which MTS is currently participating and the Transaction
Statistics window allows you to view information about
transactions since the DTC was started (example: number of
transactions that were committed, aborted, transaction
response times, etc.).
MOC Chapter 5: Accessing Data from the Middle Tier
-
There are three kinds of
database components: data consumers,
data services and data
providers. An example of a data consumer
would be a database front end written in a language such
as Visual Basic or C++. Other examples include Active
Server Pages and even the high-level ADO programmatic
interface itself. Data Services refer to the
cursor engines and query processors that take on some of
the work that the database would normally do, speeding up
operations significantly and allowing the database to
focus solely on serving data to its eventual consumers.
Finally, data
providers refer to the actual databases themselves
(both relational or non-relational). Typical examples of data
providers include SQL Server 7, Oracle and mainframe
databases.
-
UDA
(Universal Data Access) is Microsoft’s latest strategy
for universal data access. By using high-level
programmatic interfaces such as
ADO (Active X Data Objects), programmers are able to
access any kind of information from both
relational and non-relational databases. ADO works on top
of OLE-DB (the lower-end programmatic interface), which is
able to access the eventual data. In effect, OLE-DB
supercedes the older ODBC data access method by being able
to access non-relational data as well. ODBC only accesses
relational databases. ADO is also a replacement for the
older DAO (Data Access Objects) and RDO (Remote Data
Objects) data access technologies.
-
Once a data environment is
configured (at least one connection to a database is
established), you can use the Data View Window to
view information about the database’s structure (tables,
stored procedures, views, etc.).
-
Use the execute method of the
connection object when the command needs to be
issued only once. If, on the other hand, you have
to issue the command several times, use the execute method
of the command object. It takes up fewer system
resources to use one connection object (with several
command objects) than to have several distinct connections
open at the same time. Prepared command
statements also execute faster.
-
When discussing
cursors ("current set of records"),
there are different types, locations and locking
strategies available and they are distinguished by
their ability to be scrollable and or
updateable:
Cursor Type Information
Forward-Only (default)
|
not scrollable |
Read Only |
Least expensive resource-wise Fastest cursor
type Useful for filling list boxes, etc.
|
Static |
scrollable |
Updateable but changes by other users are not
immediately visible
|
Copy of records is retrieved (snapshot
information) They are used in disconnected recordsets
|
Keyset
|
scrollable |
Can’t see
inserts |
Keys are used
for each record |
Dynamic
|
scrollable |
Can see all
additions, deletions and changes |
Most flexible
cursor type Most expensive resource-wise |
Cursor Location Information:
AdUseClient
|
Used
with disconnected (client-side) recordsets
|
AdUseServer
|
(default)
|
Locking
Strategies
AdLockReadOnly
|
(default) – data cannot be changed
|
AdLockPessimistic
|
The
record is locked immediately upon entering edit mode
|
AdLockOptimistic
|
The
record is locked only when the update is requested
|
AdLockBatchOptimistic
|
Used
with disconnected recordsets
|
-
Whenever OLE-DB (lower-level
programmatic interface) issues any errors, they are stored
in the ERRORS collection, whereas whenever ADO
(higher-level programmatic interface) returns any errors,
they are sent to the Visual Basic ERR object.
Always use proper error handling to respond to both types
of errors.
Set param1 = cmd.CreateParameter("vLastName",
adVarChar, adParamInput, 20, "Smith")
cmd.Parameters.Append param1
MOC Chapter 6: Building Stored Procedures with SQL
This chapter is not heavily
emphasized on the exam. Exam 70-029 - Designing and
Implementing Databases with Microsoft® SQL Server™ 7.0
tests this knowledge in greater detail.
-
Note the difference between a
regular query, a stored
procedure and a database trigger.
Stored procedures execute much faster than queries because
they are compiled. Triggers are special stored procedures
that respond to modification attempts (insert, update or
delete) on a database. These special procedures (which
enforce the integrity of the database) are automatically
triggered in response to these attempts.
SELECT * FROM EMPLOYEES
WHERE SALARY > 75000 AND
CITY=’DALLAS’
ORDER BY LASTNAME DESC
-
Know the proper SQL syntax for
database joins. You will always have one fewer JOIN
statement than the number of tables. For example, if you
are joining 3 tables, you will have 2 JOIN statements in
the SQL statement, as illustrated below:
Table
|
Fields
|
CUSTOMERS
|
CustomerID (primary key) lastname, firstname, etc…
|
RESERVATIONS
|
CustomerID (foreign key) airlineID (foreign key)
ticketprice, etc…
|
FLIGHTS
|
airlineID (primary key) number, departuretime, etc…
|
SELECT customers.lastname,
flights.number, SUM(reservations.ticketprice) FROM customers
JOIN reservations ON
customers.customerID = reservations.customerID
JOIN flights ON
reservations.airlineID = flights.airlineID
MOC Chapter 7: Implementing Security in MTS and SQL Server
This chapter focuses on security
issues in both MTS and SQL Server. Emphasis on the exam is
placed solely on MTS security – and specifically, how it is
implemented in packets and how components are accessed between
them. There are two types of security that you can use in MTS
– declarative and programmatic. Declarative
is the most widely used of the two.
-
A role is the
name of a group (created using MTS Explorer) that is used
to define a specific group of related users - allowing
them access to components in a package. Each role defines
the names of specific users that are allowed access to the
interfaces (methods) of components within MTS
packages. In other words, whenever someone tries to gain
access to the interfaces of a component, roles determine
which users have the rights to do so.
-
Whenever a request for a
component is made from outside a package,
however, security checks are invoked. If a component in
Package A calls a method from another component in Package
B, for example, security is checked.
-
To create a role,
select the MTS package that you want to include it in and
double-click on the roles
folder. Next, click New on the Action menu and
choose Role. As an alternative, you can also right-click
on the roles folder, click New and then Role. Follow the
instructions that follow.
-
To assign roles
to components or their interfaces, select the component or
interface within it that will include the role,
double-click the Role Membership folder,
and then click New and then Role from the Action menu. You
can also right-click on the Roles Membership folder, click
New and then Role. In the dialog box that follows, select
the pre-defined roles that you would like to add to the
Roles Membership folder and then click OK.
-
When you are ready to
distribute your application, you must map Windows NT
users to your roles. You do this using Windows NT
User Manager for Domains. To add (map) users to
existing roles, open the package first, then open the
Roles folder and double click on the specific role that
you’d like to add users to. Open the Users
folder and then click on New and then Users
from the Action menu. You can also right-click Users,
choose New and then Users. In the dialog box that follows,
add your NT groups or users to the role.
-
In order for component-level
security to be enabled, package-level security must be
enabled first. As soon as package-level security is
disabled, component-level security for all components in
that package becomes disabled as well.
-
To enable or
disable security, right click
on the package or component, choose Properties
and then click the
Security tab. Finally, check or clear the
Enable authorizing checking check box.
-
There are three security
modes available in SQL Server
-
Standard
Security – uses SQL Server’s own login
validation process. Connections made to databases using
this security mode are known as non-trusted.
-
Integrated
Security – uses Windows NT to validate
SQL Server logins. Connections made to databases using
this security mode are known as trusted.
-
Mixed
Security – can use either
Standard or Integrated security.
MOC Chapter 8: Implementing
COM with Visual Basic
This chapter outlines how the COM
standard allows clients to communicate with component objects
through the interfaces which they expose. Interfaces are
represented as contracts between clients and servers which
ensure that objects always implement an interface’s
functions in a standard way. Note that emphasis on the exam is
largely on object binding and not the specific details of how
COM works.
Declaring a variable as VARIANT
is also considered to be late binding.
This type of binding also
allows the compiler to optimize access to the object and
results in two types of early binding: dispID
binding and
Vtable binding. Vtable binding is faster and
more efficient than dispID because it makes fewer method
calls to the IDispatch interface.
MOC Chapter 9: Advanced Client
/ Server Technologies
This chapter is not emphasized on
the exam.
OTHER INFORMATION covered by exam
70-175 (but not appearing in the MOC)
-
The StatusBar control
has a panels collection that begins with index 1,
not 0. It has two styles: sbrNormal and sbrSimple.
When using the simple style, use the SimpleText property
to provide messages in the one, continuous status bar. If
sbrNormal is chosen, on the other hand, use the Text
property to issue messages in one or more of the panels.
Treeview.Nodes.Add(
[Relative], [Relationship], [Key], [Text], [Image],
[Selected Image] ) as node
Cnn.Open
‘a statement similar to this one must precede those which
follow Cnn.BeginTrans Cmd.Execute
|