what is meant by typed/untyped/strongly typed datasets?

R

Rachana

Hi,
I have understood Data Sets but what is meant by typed/untyped/
strongly typed datasets. Can any one explain me or suggest any site/
article, to get these concepts (and their comparisions) cleared?
Thanks,
Rachana
 
P

Phillip Taylor


If something is strongly typed then it means you have explicitly told
the computer what kind of data you are working with. With untyped or
weakly typed languages or datasets, the system attempts to have a
guess.

For example. C# is strongly typed:

Int32 myvariable = 6; //myvariable is a number.
myvariable = "hello"; //error, you can't put a string in a number

however PHP is not:

$myvariable = 6; //myvariable is a number
$myvariable = "hello"; //myvariable is all of a sudden a string

The same thing applies to datasets with database programming. You can
apply the databases structure rigidly to your code or not.
 
C

Cor Ligthert[MVP]

Rachana,

One of the features from a dataset is that you can describe it in an XSD
file.

Visual Studio gives you a lot of possibilities to do that. As soon as you
have that XSD file you can make a class from it, that inherits the original
DataSet.

The trouble with the none strongly typed dataset is that you have yourself
to index all the tables, the columns and the items by integers, strings (and
columns for the items)

An object instanced from a Strongly Typed Dataset makes life much easier for
you.

Using a Row in a dataset means that you do
Dim myRow as DataRow = ds.Tables(0).NewRow

In a Strongly Typed dataset you do
Dim myRow as MyStronglyTypedDataset.NewMyTableRow

An item is then by instance in a non strongly typed dataset

myRow("ID")

in a strongly typed dataset it is
myRow.ID

This is much saver because the non strongly datasets give only errors on
runtime as you type something wrong. The strongly typed dataset does that at
design time.

Beside that are there properties around relations, and by instance is
nothing, and all with intelligence so you don't have to look all the time
what items you have to use and how to write them.

The trouble is with a strongly typed dataset is to get used to the names
that is generated from the XSD description for you (of course using the kind
of logic from the guys who made this class).

However as you are used to it you never want to use a non strongly dataset
anymore.

(This is all written in this message, normaly I use intelligence to get the
names, so I can have used some wrong)

Cor
 
C

Cor Ligthert[MVP]

I forgot to tell what Philip was telling however with C# samples.

The type gives that you don't have to cast the objects. In a non strongly
typed dataset everything is an object and therefore you are all the time
casting to the correct type.

However that is not the most important why I like it, because casting to the
receiver is easily done.

However this is of course done in advance for you in a Strongly Typed
Dataset.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top