ASP.NET - difference between type dataset and non-type dataset

Asked By aman on 09-Aug-11 02:31 AM
hi all,

what is the difference between Type dataset and Non-type dataset?
how to do practical demonstration of the same?

thanks and regards
Aman Khan
Ravi S replied to aman on 09-Aug-11 02:35 AM

Dataset : the dataset can be defined as collection of tables which resides in client as inmemory storage.

This can be classifides into two types

1.untyped dataset: the dataset which follows the unstructure is called as Unstructured dataset.

Ex : dim ds as new dataset();

2.Typed Dataset: typed dataset can be inherited from dataset class by providing strongly typed properties and methods.

typed Dataset: Structure+strongly typed properties and methods.

Ravi S replied to aman on 09-Aug-11 02:37 AM

Untyped DataSets



// Weak Type DataSet

DataSet weakDataSet = new DataSet();





foreach(DataTable dt in weakDataSet.Tables)


foreach(DataRow dr in dt.Rows)


foreach(DataColumn dc in dt.Columns)







Most of these problems are solved by using Strongly Typed DataSets. Let's see how we can use them.

Strongly Typed DataSets:



Below I made an instance of the typed dataset "MyDataSet".

MyDataSet ds = new MyDataSet();



Now let's see that how easy it is to refer to the column and rows that are present in the dataset.





Now let's see how we can iterate through the dataset.

foreach(MyDataSet.ArticlesRow articleRow in ds.Articles)




 As you see that now we don't have to type much code in order to iterate through the dataset. We just used the dataset row to iterate through the dataset collection and finally we added the items in the Listbox.




As you can see above each column that is included in the Typed DataSet comes with a method which let's the user know that if the current row that he is accessing is null or not. This is very convenient for columns that can have null values. If you don't check for null values "Object reference not set to an instance" error will be fired.





xsd MyDataSet.xsd /c




Many people are using Typed DataSets as business objects. There are some problems in this approach which I will address in my future article "Typed DataSets Vs Entity Classes".

I hope you enjoyed the article, happy programming !


dipa ahuja replied to aman on 09-Aug-11 03:00 AM



Anoop S replied to aman on 09-Aug-11 03:32 AM
A DataSet can be Typed or Untyped. The difference between  the two lies in the fact that a Typed DataSet has a schema  and an Untyped DataSet does not have one. It should be noted that the Typed Datasets have more support in Visual  studio.Typed Dataset provide compile time type checking. Also it  provides the names of the Columns of the types we are using for that typed data set. This is something we dont get in  the normal datasets.
Jitendra Faye replied to aman on 09-Aug-11 04:14 AM

Typed Dataset (TDS):

TDS is added using MS VS as .xsd file by right clicking solution and clicking ‘Add New Item’ and by selecting DataSet. We can also generate TDS using xsd.exe, a VS .NET command prompt tool. TDS is easy to use. TDS is also called as strongly typed dataset because we get compile time errors in case there is any type (datatype) mismatch. Strongly TDS is slow in terms of performance. It is used only in small applications.

Untyped Dataset (UTDS):

In our web applications we normally use UTDS. UTDS is not easy to use but easy to administer. UTDS is so called because we get runtime errors in case there is any type (datatype) mismatch. UTDS is fast in terms of performance. It is used in small as well as in large enterprise level applications. In order to create UTDS we have to create each row and column of datatable in a dataset manually with specifying the datatype of each column as well.


XSD.exe is a tool in .NET framework SDK that generates the TDS using xml (schema) file generated when we drag a table into TDS using MS VS designer. An example of TDS in our code is:

DataSet dsPersons = new Persons().GetPersons();

gvPersons.DataSource = dsPersons;


Hope this will help you.

Riley K replied to aman on 09-Aug-11 04:35 AM
A typed dataset gives us easier access to the contents of the table through strongly typed programming that uses information from the underlying data schema. A typed DataSet has a reference to an XML schema file:

Dim s As String
s = dsCustomersOrders1.Customers(0).Customer

In contrast, if we are working with an untyped DataSet, the equivalent code looks like this:

Dim s As String
s = _ CType(dsCustomersOrders1.Tables("Custome

As the syntax is much simpler and more practical, using typed Datasets is much more handy.