ASP.NET - example of difference between Type DataSet And Non-type dataset.

Asked By aman on 09-Aug-11 04:58 AM
hi all and thanks for your previous help

i want to know what exactly the practical demonstration difference between the both please help me with some example..........if possible.

thanks and regards
Aman Khan
Jitendra Faye replied to aman on 09-Aug-11 04:58 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.


Note:

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;

gvPersons.DataBind();

Hope this will help you.

Riley K replied to aman on 09-Aug-11 04:59 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
ID

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
rs").Rows(0).Item("CustomerID"), String)

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

Regards
Anoop S replied to aman on 09-Aug-11 05:00 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 05:01 AM
Typed Dataset:

s = dsCustomersOrders1.Customers(0).CustomerID

Untyped Dataset:

string s = (string) dsCustomersOrders1.Tables["Customers"].Rows[0]["CustomerID"];

typed dataset is generally used as it is easy to use and moreover gives errors at compile time...compared to untyped which gives on run time
Anoop S replied to aman on 09-Aug-11 05:02 AM
Typed dataset:-
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.
eg:

typed datasets
string s;
s=dscust.customer(0).customerid;

or

//using strongly typed dataSet
private NorthwindDataSet.CustomersRow GetSelectedRow()
{
string selectedCustomerID =
CustomersDataGridView.CurrentRow.Cells["CustomerID"].Value.ToString();
NorthwindDataSet.CustomersRow selectedRow =
northwindDataSet1.Customers.FindByCustomerID(selectedCustomerID);

return selectedRow;
}

Untyped dataset:-
Untyped dataset is one which is filled/generated using a
DataAdapter and a command object.
eg:-

untyped dataset
string s;
s=Convert.toString(dscust.customer(0).customerid);

or

My solution here using untyped DataSet
{
DataGridViewRow row = CustomersDataGridView.CurrentRow;
DataRow selectedRow = (row.DataBoundItem as DataRowView).Row;
}

Sreekumar P replied to aman on 09-Aug-11 06:04 AM
Hi,

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.
Radhika roy replied to aman on 10-Aug-11 10:10 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.

Hope this will help you.

Follow this link-

http://www.dotnetspider.com/forum/22473-Diff-between-Typed-dataset-Untyped-dataset.aspx

Radhika roy replied to aman on 10-Aug-11 10:11 AM

Typed versus Untyped Datasets


Datasets can be typed or untyped.
 A typed dataset is a dataset that is first derived from the base DataSet class and then uses information in an XML Schema file (an .xsd file) to generate a new class. Information from the schema (tables, columns, and so on) is generated and compiled into this new dataset class as a set of first-class objects and properties.

Note For more information about dataset schemas, see XML Schemas and Data.

Because a typed DataSet class inherits from the base DataSet class, the typed class assumes all of the functionality of the DataSet class and can be used with methods that take an instance of a DataSet class as a parameter 

An untyped dataset, in contrast, has no corresponding built-in schema. As in a typed dataset, an untyped dataset contains tables, columns, and so on — but those are exposed only as collections. (However, after manually creating the tables and other data elements in an untyped dataset, you can export the dataset's structure as a schema using the dataset's WriteXmlSchema method.)

You can use either type of dataset in your applications. However, Visual Studio has more tool support for typed datasets, and they make programming with the dataset easier and less error-prone. 

Contrasting Data Access in Typed and Untyped Datasets
The class for a typed dataset has an object model in which its tables and columns become first-class objects in the object model. For example, if you are working with a typed dataset, you can reference a column using code such as the following:


// C#
// This accesses the CustomerID column in the first row of 
// the Customers table.

string s;
s = dsCustomersOrders1.Customers[0].CustomerID; 

In contrast, if you are working with an untyped dataset, the equivalent code is:


// C#
string s = (string) dsCustomersOrders1.Tables["Customers"].Rows[0]["CustomerID"]; 

Typed access is not only easier to read, but is fully supported by IntelliSense in the Visual Studio Code Editor. In addition to being easier to work with, the syntax for the typed dataset provides type checking at compile time, greatly reducing the possibility of errors in assigning values to dataset members. Access to tables and columns in a typed dataset is also slightly faster at run time because access is determined at compile time, not through collections at run time.

Even though typed datasets have many advantages, there are a variety of circumstances under which an untyped dataset is useful. The most obvious scenario is that no schema is available for the dataset. This might occur, for example, if your application is interacting with a component that returns a dataset, but you do not know in advance what its structure is. Similarly, there are times when you are working with data that does not have a static, predictable structure; in that case, it is impractical to use a typed dataset, because you would have to regenerate the typed dataset class with each change in the data structure.

Hope this will help you.