An Introduction to

baasopchoppySecurity

Nov 5, 2013 (3 years and 9 months ago)

190 views


An Introduction to




and


Visual Basic.net











Tem McGallagher


April 2002
Tem McGallagher

Page
2

11/5/2013

Contents


AN OVERVIEW OF THE V
ISUAL STUDIO.NET FRA
MEWORK
.........................

3

.net Framework Components

................................
................................
..........................

3

Web Services

................................
................................
................................
..................

4

User Interface

................................
................................
................................
..................

4

Data and XML

................................
................................
................................
................

4

Base Class Library

................................
................................
................................
..........

4

The Common Language Runtime

................................
................................
...................

5

System
Namespace

................................
................................
................................
............

6

THE .NET IDE
................................
................................
................................
.......

8

VISUAL BASIC.NET

................................
................................
............................

9

Visual Basic.net Data Types

................................
................................
.............................

9

The
System.Object

Class

................................
................................
...............................

10

Garbage Collection in Visual Basic.net

................................
................................
........

10

Object
Oriented Programming in Visual Basic.net

................................
.....................

11

Visual Basic.net Classes


Checking Account Sample

................................
.................

11

Visual Basic.net


A High Level Summar
y

................................
................................
...

13

The Framework

................................
................................
................................
.............

14

Syntax

................................
................................
................................
...........................

14

Distribution of Applications

................................
................................
.........................

14

Data Access and XML

................................
................................
................................
..

15

ACCESSING DATA WITH
ADO.NET

................................
................................

16

XML in Visual Basic.net
................................
................................
................................
.

18

ASP.NET AND WEB SERV
ICES

................................
................................
.......

20

A final note on ASP.net

................................
................................
................................

21

Web Services
................................
................................
................................
....................

21

Tem McGallagher

Page
3

11/5/2013

An overview of the Visual Studio.net Framework


Unless you have been living under a rock for the past year, you must have heard of .net
(“dot net”) by now. What is .net? Is it a new operating environment? Is it a new
language? Is it
a new way of developing distributed applications? The answer is “Yes”:
.net is all of these things and more.


The .net world was created by Microsoft to allow users to have access to their
information, files, or programs anywhere, anytime, and on any plat
form or device.


When Microsoft introduced the first Windows operating system, it took application
development and system design to a new level: multi
-
tasking. With each new version of
Windows, multi
-
tasking has been driven more towards distributed proc
essing and .net is
the next step.


Visual Studio.net has an entirely new, object
-
oriented framework. In this paper I will
introduce you to some of features in Visual Studio.net, however, I will focus mostly on
Visual Basic.net and draw some comparisons
to its predecessor VB 6. The reader of this
paper will not be able to start developing code in Visual Basic.net after reading, but
should have a high
-
level view of the changes in Visual Basic.net and how they differ
from previous versions.



.net Framewo
rk Components


Visual Basic
Common lanaguage specification
Web Services
User Interface
Data and XML
Base class library
Common language runtime
C++
C#
...
Visual Studio .NET
Framework, Languages and Tools

Figure
1

-

An overview of the .net Framework

Tem McGallagher

Page
4

11/5/2013

As shown in Figure 1, Visual Basic sits at the top of the framework (along with the other
languages in Visual Studio.net). Below that is the
Common Language Specification
(CLS). This specification is a set of rules that govern the minimum language features
that must be supported to ensure that a language will interoperate with other CLS
-
compliant components and tools. As long as a language co
nforms to the CLS, it is
guaranteed to work with the CLR. In this way, when third
-
party compilers target the .net
framework, as long as they conform to the CLS, the code is guaranteed to work.


You might also notice that VB is now and “equal” or peer of C
++, C# and any other
language that is .net compliant. Visual Basic.net shares the same variable types, arrays,
user
-
defined types, classes, graphical forms, visual controls and interfaces as these other
languages.


Web Services


Web Services provide a Web
-
enabled user interface with tools that include various
HTML controls and Web controls. Forms creating using Web Services are the same as
forms created for a Windows application. The code behind a Web form is the same as
the code behind a Windows form.
The markup language that is used by Web forms is
still there, but the Web form applications generate it for you.


User Interface


At the same level as Web Services is the User Interface. The User Interface is where
Windows forms live. It also provides co
de for drawing to the screen, printing, rendering
text and displaying images.


Data and XML


Both Web Services and the User Interface sit on top of the Data and XML block. As you
will learn later in this paper, XML (or extensible markup language) plays ju
st as
important of a role as data. XML is used to provide a text view of data that can be shared
between services on the same PC or passed through a firewall to a web server across the
country using SOAP (more on SOAP a little later).


Base Class Library


The base class library (BCL) is underneath the Data and XML block. This area is the
origin for the base class of all .net programs. Everything in Visual Basic.net is an object,
and all objects originate from a class named
System
. The BCL also provides
collections,
localization, text objects, interoperability with non
-
.net code and ActiveX controls and a
variety of other services.



Tem McGallagher

Page
5

11/5/2013

The Common Language Runtime


At the base of the .net framework is the common language runtime (CLR). Much like the
Java
Virtual Machine, the CLR is needed to make .net code run on any machine.



Base class library support
Thread support
COM marshaler
Type checker
Security engine
Class loader
Common Language Runtime
Exception manager
Debug engine
IL to native
components
Code
manager
Garbage
Collector

Figure
2

-

Common Language

Runtime services


The CLR is a set of resources that any .net program can take advantage of, from an
y .net
-
supported language. All languages will be more equal in capability than they ever have
before.


The CLR includes support for the BCL, where the architecture for controls and forms
actually live. It is also responsible for managing threads and exce
ptions (replacing the
Err object in VB 6). Garbage collection is also handled by the CLR.


The CLR takes code generated by VB and converts it to the native language of the
current platform. Through this conversion, the magic of multi platform execution i
s
achieved. Now VB programmers can write code in VB syntax and the CLR is
Tem McGallagher

Page
6

11/5/2013

responsible for converting it to any platform that can run the CLR. The programmer is
removed several layers from the hardware and doesn’t really need to know what platform
his/her

code is running on.


One additional service of the CLR is handling bad code. You have probably heard stories
of rogue code that overran buffers and trashed a machine, killing all other programs along
with it. By design, this cannot happen with code writ
ten in Visual Basic.net.



System Namespace


The
System

namespace includes all classes that represent the base data types used by all
Visual Basic.net applications. In .net, all of the base data types are
Object, Byte, Char,
Array
, and so on. Many of the
se correspond to the data type in classic VB.


In addition to the base data types, the
System

namespace contains nearly 100 classes that
provide functionality ranging from handling exceptions and forming delegates to dealing
with the core run
-
time concepts

such as application domains and the automatic memory
manager. The
System

namespace also contains 25 second
-
level namespaces, listed in
Table 1. Looking at these, you can see how the namespace convention logically
separates functionality.


Table 1


Seco
ndary namspaces in the
System

Namespace

Namespaces

Description

System.CodeDom

Contains classes that can be used to represent the elements and
structure of a source code document.

System.Collections

Contains interfaces and classes that define various coll
ections
of objects, such as lists, queues, arrays, hash tables and
dictionaries.

System.ComponentModel

Provides classes that are used to implement and license
components.

System.Configuration

Provides classes that give system run times, administrative
to
ols, applications and other consumers of configuration
information access to configuration information.

System.Data

Consists mostly of classes that constitute the Microsoft
ADO.net architecture.

System.Diagnostics

Provides classes to debug applications

and trace the execution
of code.

Ssytem.DirectoryServices

Provides access to Active Directory from manage code.

System.Drawing

Provides access to the GDI+ basic graphics functionality.

System.EnterpriseServices

Provides transaction
-
processing functio
nality.

System.Globalization

Provides localization information on elements such as the
current culture, formatting, data, and time for specific locales.

System.IO

Provides types that allow synchronous and asynchronous
reading from and writing to data str
eams and files.

System.Management

Provides classes for manager of system object and events.

System.Messaging

Provides classes to connect to message queues on the network,
send messages to queues and receive or “peek” messages from
queues.

Tem McGallagher

Page
7

11/5/2013

Namespaces

Description

System.Net

Pro
vides a simple programming interface to many of the
protocols found on the network today.

System.Reflection

Contains classes and interfaces that provide a managed view of
types, methods and fields, with the ability to dynamically create
and invoke types.

System.Resources

Provides management of resources, such as a resource that
contains culture
-
specific information.

System.Runtime

Provides infrastructure services,

System.Security

Provides the underlying structure of the .net framework security
system, i
ncluding interfaces, attributes, exceptions and base
classes for permissions.

System.ServiceProcess

Provides classes to install and run services (non
-
interface
executables).

System.Text

Contains classes representing ASCII, Unicode, UTF
-
7 and
UTF
-
8 charac
ter encoding; abstract base classes for converting
blocks of characters to and from blocks of bytes; a helper class
that manipulates and formats
String

objects without creating
intermediate instances of
String
.

System.Threading

Provides class and interfac
es that enable multithreaded
programming.

System.Timers

Provides two components that raise an event on an interval or
more complex schedule.

System.Web

Supplies classes and interfaces that enable browser
-
server
communication.

System.Windows.Forms

Contai
ns classes for creating Windows
-
based applications and
classes for many controls that can be added to forms.

System.Xml

Contains XML classes that provide standards
-
based support for
processing XML.


Tem McGallagher

Page
8

11/5/2013

The .net IDE



Figure
3

-

Th
e .net IDE


One of the biggest improvements with .net, in my opinion, is the new common IDE. As
you can see in Figure 3, the IDE contains a little of all the different classic Visual Studio
languages. There is an output window similar to the one in C++,
the properties window
similar to the one in VB; but best of all are the “slide
-
in” capabilities of the different
explorer windows.


There is now a server explorer that slides
-
in from the left side of the IDE. This explorer
allows the developer to have acc
ess to operating services, data connections, and best of
all, SQL server. I cannot tell you how many times I’ve wished that I could change a
stored procedure or table design without having to load SQL Enterprise Manager to do
so. With the .net IDE, all o
f the tools are found right in the same application. With the
use of the “thumb
-
tack”, you can minimize explorers to gain more space for your code
window if needed.



Tem McGallagher

Page
9

11/5/2013

Visual Basic.net


Now it’s time to take a look at Visual Basic.net, the main focus of t
his paper. I am going
to assume that the reader is already at least familiar with writing applications using VB 6
or earlier. The intent of this paper is to point out what is new in Visual Basic.net and not
how to develop applications using Visual Basic.n
et.



Visual Basic.net Data Types


Before we can get into the Visual Basic.net code, we need to start by exploring the
changes to data types. Hopefully, you are not a programmer that insisted on using the
Variant

data type consistently in your code…if you

did, you will have a more difficult
time adjusting to the new data types in Visual Basic.net. The
Variant

data type no longer
exists in Visual Basic.net. (Another data type that did not make the transition is the
Currency

type.)


The primitive data type
s still exist (
Integer, Boolean, Long, etc.
), the main difference now
is that these data types are all structure types in the
System

namespace and are referred to
as
Value Types
.


Value types are always accessed directly. In fact, you can’t create a refer
ence to a value
type. And unlike reference types, setting a value type to Null is not possible. Value
types always hold a value, even if one hasn’t been assigned yet. When a value type
variable is dimensioned, it’s initialized to a value representative
of its type. For example,
if you dimension a variable to
Integer
, the Visual Basic.net compiler automatically
initializes the variable to 0.


Consider the following VB 6 variable declaration:


Dim intValue As Integer


This code is still valid in Visual Ba
sic.net, however, you can also do the following in
Visual Basic.net:


Dim intValue As Integer = 5


Being able to dimension and set the value of a variable at the same time is a much
welcome change.


For you Java users out there, there are also some new fea
tures to the value types you are
already familiar with: formatting and conversion. In VB 6, the Format() function and
functions like CStr() or CInt() provided us with the means of converting between data
types. Now, each data type has its own built in me
thods to handle conversion, equality
checks (there’s even a ToString() method in these structures.)


Tem McGallagher

Page
10

11/5/2013

A final note on data types: Visual Basic.net is a type
-
safe language (you can only access
a variable through the type associated with that variable). We s
hould be used to using
Option Explicit

in VB code to require variable declaration, but Visual Basic.net has a new
directive called
Option Strict
. This new directive prevents you from trying to overwrite
data with a different data type and should always be

included at the top of your class and
form code.



The
System.Object

Class


The
System.Object

class is much like the
Object

class in Java. The
System.Object

class is
the super class of all classes the in .net framework

it’s the only class in .net that do
es
not inherit from any other object type. All objects must either explicitly or implicitly
declare support for exactly one other object type. In .net it is impossible to use a class
that does not inherit from
System.Object
.


There are six methods inhe
rited by all classes that come from the
System.Object

class, see
Table 3 below.


Table 3


Inherited

Methods from
System.Object

Namespaces

Access

Description

Equals

Public

Takes another object as a parameter and returns a
Boolean

that indicates whether th
e two objects are equal.

GetHashCode

Public

Returns an integer hash code that represents the object’s
value. This code is usually used as a key when the object
is added to a collection. Two identical objects should
generate the same code.

Finalize

Prot
ected

The CLR calls an object’s
Finalize

method to notify the
object that the object is about to be destroyed. This
method really does nothing and is overridden by the
class.

MemberwiseClone

Protected

Creates a shallow copy of the object.

GetType

Public

Returns an instance of
System.Type
, which is used to get
information about the object through metadata.

ToString

Public

Returns a string representation of the object.



Garbage Collection in Visual Basic.net


In VB 6, when you were finished using an obj
ect, you simply set it to nothing and the
object would be released. This is no longer the case with Visual Basic.net. In Visual
Basic.net, when a variable loses scope, the CLR destroys the object and removes it from
the stack automatically for you.



Tem McGallagher

Page
11

11/5/2013

Obj
ect Oriented Programming in Visual Basic.net


Many people have asked for this for a long time and now Microsoft has delivered. As
you may have guessed by now, the major difference in Visual Basic.net is that it is now
truly object
-
oriented.


Inheritance

is one of the fundamental aspects of object
-
oriented programming. Through
inheritance, you can derive classes from other classes that have already been written.
Even a Windows form is now inherited, just look at the code at that begins each form:


Publi
c Class Form1


Inherits System.Windows.Forms.Form


As you may know, when a class inherits from a base class, it inherits the properties and
methods of that class (or its
members
). You can then use or add these members in your
own class in whatever way you

need.


Visual Basic.net couldn’t be truly object
-
oriented without polymorphism, which it of
course has. Using the
Windows.Forms.Form
class an example: you create two Windows
forms in your application, they both have a Close() method, but what the code do
es in
each form can be different (an usually is). The point is that each form inherits from the
Windows.Forms.Form

class, but each has its own “form” (no pun intended). After all,
the word polymorphism literally means “many forms”.


One other change in V
isual Basic.net that relates to OOP is method overloading. VB
always had a “sort of” way of overloading functions or methods by using the
Optional

keyword in the function/method declaration. In Visual Basic.net (again, much like in
Java), when you write
a definition for a method/function, you can overload it with the
different parameters as needed.



Visual Basic.net Classes


Checking Account Sample


The following is a short example of a class written in Visual Basic.net. After the code, I
will examine
the features of the class.


Code for the Checking class:


Option Strict On

Imports System

Namespace Accounts


Public Class Checking


Private m_strAcctName As String = ""


Private m_strAcctNumber As String = ""



Sub New()



MyBase.New()


End Sub

Tem McGallagher

Page
12

11/5/2013



Sub New(ByVal strAcctName As String, ByVal strAcctNumber As
String)


MyBase.New()


m_strAcctName = strAcctName


m_strAcctNumber = strAcctNumber


End Sub



Overridable Fu
nction Serialize() As Boolean


If ((m_strAcctName <> "") And (m_strAcctNumber <> "")) _


Then


Return True


Else


Return False


End If


End Function


#Region "Account Properti
es"



Property AccountName() As String


Get


AccountName = m_strAcctName


End Get


Set(ByVal Value As String)


m_strAcctName = Value


End Set


End Property



Pro
perty AccountNumber() As String


Get


AccountNumber = m_strAcctNumber


End Get


Set(ByVal Value As String)


m_strAcctNumber = Value


End Set


End Property


#End Region


End

Class

End Namespace


Examining the Checking class and Accounts Namespace:


Option Strict On



To reiterate, this statement checks for possible problems in the
code that would try to overwrite different data types (for example if: intI = strSomething).


Im
ports System



This imports the classes in the System Namespace.


Tem McGallagher

Page
13

11/5/2013

Namespace Accounts

-

Namespaces

are used to group related types into a
hierarchical categorization. We’ve already explored the System namespace, I’ve chosen
to use Accounts for my namespace
. Later, I may want to add a Savings account or a
Money Market account class to the Accounts namespace that would have different
properties.


Public Class Checking



Begins the definition of the class.


Next, I declare private memory variables that assist

me in data hiding. While these
variables will hold the actual value of the Account Name and Account Number, the
consumer of this class can only access these values by using the public methods.


Sub New()
-

This is the default constructor for the class. Y
ou can see the I have
overridden the New() constructor with one that will also allow the consumer to pass
initial values to the class during construction.


MyBase.New()
-

This must be the first line of code in the constructor methods. This
calls the base
-
c
lass constructor that the class is derived from (in this case it is
System
).


Overridable Function Serialize()



Because Visual Basic.net methods are
not overridable by default you must explicity use the keyword
Overridable

for methods
you want consumers t
o be able to override.


Property AccountName()
-

The traditional Let/Set methods have been replaced in
Visual Basic.net with Get/Set methods instead that are “wrapped” inside of the
Property

block.



To actually implement this class in your Visual Basic.net

code you would assign the class
to a variable using the following code:



Dim clsChecking As New Accounts.Checking()


This calls the default constructor for the class. Then to set the properties of the class, you
could do the following:



With clsCheckin
g



.AccountName = “AmSouth Checking Account”



.AccountNumber = “53
-
11123221”


End With




Visual Basic.net


A High Level Summary


As you can probably tell by now, there are a lot of things that are new with Visual
Basic.net, but there are also some thin
gs that haven’t changed. One could easily write a
Tem McGallagher

Page
14

11/5/2013

book on this topic, but with this paper we will keep it on a high level…so let’s review
some of the major changes in Visual Basic.net.


The Framework


There are many goals of the .net framework, however, t
he main goal, and benefit, is that
of the CLR. With the CLR, objects that are written in C++, C# and Visual Basic.net can
all be used in any project that is targeted for the .net framework. If you are familiar with
COM, a subject I haven’t touched on in
this paper, it’s time to forget what you
know…COM no longer exists in .net (there is backward compatibility for ActiveX
controls and DLLs, however, I would expect this to go away in future releases of .net).


The Framework is meant to be the “great equaliz
er”. No longer do we, as programmers,
have to worry about the underlying architecture/hardware we’re running on; if the PC
meets the minimum requirements for the .net Framework, then your Visual Basic.net
application should run without problem on that PC.



Syntax


Much of the syntax in Visual Basic.net has remained the same, however, as I’ve already
mentioned, everything in Visual Basic.net is now an object, even the data types. You can
still use data types much the same as before, however, since they ar
e now objects, the
programmer has greater control and flexibility when manipulating them.


Visual Basic.net is type
-
safe. Since the
Variant

data type no longer exists, you cannot
simply assign the value of an
Integer

to a
String

for example; this will cau
se a runtime
error. Using the
Option Strict

statement at the beginning of your code will help eliminate
these types of errors because the compiler will catch them.



Distribution of Applications


This is a major, and very much welcome change, in Visual Ba
sic.net. Today, when you
create a VB 6 application that uses COM components, you have to remember to always
package the COM components with your application. Furthermore, you’d better make
sure you are packaging the right version of the components or you

will get trapped in
DLL Hell!


With Visual Basic.net, your target audience for the application must first install the .net
Framework on their PC(s). Next, you simply create a folder and copy your application
and any supporting files (help files, etc.)
to that folder and you’re finished. It really is
that simple! When the user wants to uninstall your application, they simply delete the
folder containing the application. There is no risk or worry of un
-
registering components
or removing shared componen
ts that cause other applications to no longer function.


Tem McGallagher

Page
15

11/5/2013


Data Access and XML


I will talk more about ADO.net in one of the following sections, but I did want to
mention here that data access with Visual Basic.net and ADO.net has changed
immensely. The
Re
cordSet

object no longer exists in ADO, instead we now use a
DataSet

object.


The main idea behind the
DataSet

object is this: after you have defined all you need
about the data source, you use a
DataSetCommand

object to connect to the data source
and
retrieve the data you want then disconnect from the data source. This frees up server
resources because the server does not have to maintain as many concurrent connections.
(This principle is much the same as using a disconnected recordset, but as you’ll

see later,
there are also other features in the
DataSet

object that disconnected recordsets cannot
handle.)


At the root of all data in .net is XML. I will explain later why XML is used and you will
hopefully see the beauty of it. If you have ever devel
oped distributed applications, or
wanted to, .net gives you the tools to do this much easier than before. If you refer back
to the table containing the
System

Namespace, you’ll see
System.Xml

at the end of the
list…i.e., one could also say that at the ro
ot of ALL things in .net is XML.



Tem McGallagher

Page
16

11/5/2013

Accessing Data with ADO.net


Data access with Visual Basic has come a long way in a relatively short period of time.
After all, Microsoft released three versions of Visual Basic before database access was
ever included.

In VB 3, Microsoft introduced DAO (Data Access Objects), which used
the Microsoft Jet Engine to connect to local databases. You could use DAO to connect to
databases on a server, but the performance was poor because DAO was optimized for
local access.


Following DAO came RDO (Remote Data Objects) and then finally ADO (ActiveX Data
Objects). These access technologies were designed with client/server in mind, but with
the move away from a client/server to an n
-
tier approach to system design, something
new

was needed; enter ADO.net.


As mentioned earlier, the
Recordset

object no longer exists in ADO.net. The successor,
the
DataSet

object now gives us a look at all of the data. It can model data logically or
abstractly, because unlike the
RecordSet
, the
Da
taSet

is not a container that can hold only
rows of data. The
DataSet

can actually hold multiple tables and the relationships
between them.


Let’s say for example you wanted to query data from two tables in a database that are
joined together. In traditi
onal ADO, you would execute a SQL query that placed the
results in the
RecordSet

object. In ADO.net, using the
DataSet

object, the two tables
themselves are placed in the data set and you then perform the needed query afterwards.
The advantage of this me
thod is not obvious, but what if there was some bit of detail in
one of the tables your query left out? You would then, possibly, have to create another
RecordSet

to query the additional information you needed.


Previous releases of ADO had support for
XML, but it was crude at best. If you don’t
know what XML is by now, I suggest you start surfing or buy a good book on XML: it’s
here to stay.


For several years now, many businesses have been using XML to exchange data. The
problem has been that both en
tities had to agree in advance on the format of the XML
document, because there were not any languages that would give you an easy way to
access XML data. Microsoft introduced the use of XML in ADO in version 2.1. The
programmer could either save a recor
dset to XML and vice
-
versa; the trouble was that
Microsoft defined the format of the XML and no other platforms had native support for
it. Thanks to W3C, there is now a standard XML schema for recordsets and Microsoft
uses this standard in ADO.net. I am
not sure if other companies have yet adopted the
standard, but you can be assured they will soon if they haven’t already.


Figure 4 depicts data flow from a data source to a data consumer using ADO.net. First
we connect to and retrieve tables from a relat
ional database. The tables are each placed
in an in
-
memory
DataSet

object using
DataSetCommand

objects. These
DataSetCommand

objects specify the tables (or a subset thereof) that we are interested in.
Tem McGallagher

Page
17

11/5/2013

After the
DataSet

is filled, the connection to the d
atabase is immediately closed. We can
then build the relationship between the individual tables within the
DataSet

itself and
send the data, via XML, to any client application.



Figure
4

-

ADO.net data

flow


Tem McGallagher

Page
18

11/5/2013

Table 4 below lists some of the differences between ADO and ADO.net.


Table 4


A Comparison of ADO and ADO.net Features

Feature

ADO

ADO.net

Memory
-
resident
data

Use the Recordset object, which
looks like a single table.

Uses the DataSet object, wh
ich can
contain one or more tables
represented by DataTable objects.

Relationships
between multiple
tables

Requires the JOIN query to
assemble data from multiple
database tables in a single result
table.

Supports the DataRelation object to
associate row i
n one DataTable
object to rows in another DataTable
object.

Accessing data

Scans Recordset rows
sequentially.

Permits non
-
sequential access to
rows in a table. Follows
relationships to navigate from rows
in one table to corresponding rows in
another tabl
e.

Disconnected access

Provided by the Recordset
object, but generally supports
connected access represented
by the Connection object.
Communicates with a database
with call to an OLE DB
provider.

Communicates to a database with
standardized calls to a
D
ataSetCommand object.

Programmability

Uses the connection object to
transit commands.

Uses the strictly typed programming
characteristic of XML. Data is self
-
describing. Underlying data
constructs such as tables and rows do
not appear in the XML, making

code
easier to read and to write.

Sharing disconnected
data between tiers or
components

Uses COM marshaling to
transmit a disconnected
recordset. Supports only those
data types defined by the COM
standard.

Transmits a DataSet with an XML
file. The XML
format places no
restrictions on data types and
requires no type conversion.

Transmitting data
through firewalls

Problematic because firewalls
are typically configured to
prevent system
-
level requests
such as COM marshaling of
binary objects.

No problem b
ecause the ADO.net
DataSet object uses text
-
based XML,
which can pass through firewalls.

Scalability

Database locks and active
database connections for long
durations contend for limited
resources.

Disconnected access to database data
limits contention fo
r limited database
resources.



XML in Visual Basic.net


You cannot do anything in Visual Basic.net without XML being involved somewhere. It
may not be on the surface, but it is there in the underlying data. Chances are that if you
are only developing W
indows applications for use on a single PC, you will not use XML
Tem McGallagher

Page
19

11/5/2013

very often; but if you want to query or update data from a remote data source (on the
Internet or Intranet), you will need to understand what XML is and what it can do. And
you will, of cour
se, use ADO.net as the mechanism to do this.






Tem McGallagher

Page
20

11/5/2013

ASP.net and Web Services


Web Forms (the controls and classes .net provides for building Web pages) and Web
Services (programmable application logic accessible by standard Internet protocols) are
part of t
he framework for Internet functionality included in Visual Basic.net and are
known under the umbrella of ASP.net. If you have worked with ASP (Active Server
Pages) before, you will be surprised at how much different and more efficient ASP.net is.
ASP.net

encompasses a completely new programming object model. It replaces the VB 6
WebClasses and DHTML pages. Not only that, but the ASP.net programming model is
also more consistent and easier to use.


Some of the key features of ASP.net are:




Language Indep
endence.

ASP.net allows you to use compiled languages,
providing better performance and cross
-
language compatibility.




Simplified development.
ASP.net makes even the richest pages
straightforward and easy to write.




Separation of code and content.
Each
Web Form has a code module with
the same name but with the extension .vb. This so
-
called
code behind the
page

contains the program logic code, while the Web Form contains the visual
components.




Improved scalability.
New session
-
state features make it ea
sy to create Web
Forms that work on Web server farms.




Support for multiple clients.

ASP.net controls can automatically detect the
client and optimize themselves for a consistent look and feel. You no longer
have to write separate code for different brow
sers.




New Web Forms controls.

The new controls can output HTML 3.2 for
down
-
level browsers while taking advantage of the runtime libraries for
enhanced interactivity on richer clients. Our programs can now output to a
whole new range of platforms such a
s PDAs.




Server
-
side processing.
ASP.net changes each page into a server
-
side object.
More properties, methods, and events can be used with your code to create
content dynamically. The
runat
-
“server”

attribute converts the HTML
element into a server
-
sid
e control that is visible and therefore programmable
within ASP.net on the server. Events raised by Web Form controls are
detected and the appropriate code is executed on the server in response to
these events.


Tem McGallagher

Page
21

11/5/2013


A final note on ASP.net


ASP.net is writ
ten entirely in the new C# language. All ASP.net pages have the .aspx file
extension, which allows both .asp and .aspx files to be run on the same machine under the
existing ASP runtime.



Web Services


In very general terms, ASP.net pages are for human i
nteraction with a Web server, and
Web services are for programmatic interaction with a Web server. Web services are a
general model for building applications that can be implemented for any operation that
supports or requires communication over the Intern
et.


DCOM (which stands for Distributed COM) has been around for a long time and is
widely used today by many developers. DCOM allows us to distribute “tiers” or single
components in an enterprise solution; problem is DCOM uses protocols that can only be
shared between computers running Microsoft operating systems.


Web services uses a new technology called SOAP (Simple Object Access Protocol),
which doesn’t rely on operating systems or network protocols but uses XML and HTTP
to perform remote requests;
thereby making it usable on non
-
Microsoft platforms as well.


SOAP is basically a message exchange protocol that uses HTTP and XML. HTTP is
used as the transport because it uses port 80 and practically any computer with Internet
access is allowed in and o
ut of a firewall using port 80. XML is used for formatting the
messages.


The key advantage of Web services is that is allows software companies to create
services that can be marketed to other companies. Let’s say, for example, we’ve been
asked to dev
elop a web site for our company, which does business in different parts of
the world. Obviously there will be money conversions involved in this application. In
order to keep up with the daily exchange rates, we would have to develop our own
system that
updates the exchange rates daily. But what if we instead used a Web Service
provided by a bank? Each time we need an exchange rate, we simply make a request to
the bank’s Web Service. The benefits of the scenario are obvious, but in addition to the
obvi
ous, is the fact that we have a guarantee from the bank that the rates are valid.


There are already a number of businesses offering Web Services on the Internet. There is
even an Internet based registry that can be searched for a usable Web Service. You

can
imagine that some of these services will be charged, while other may not (where it’s in
the best interest of the business offering the service to provide it free of charge).


Some authors are predicting that Web Services may very well become the new s
tandard
for B2B integration over the Internet.