C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

Difference Between Typed Data set and UnTyped Datase


Posted Date: 24 Nov 2008      Posted By: MURUGESAN      Member Level: Silver     Points: 1   Responses: 3



Difference Between Typed Data set and UnTyped Datase in C# with example?




Responses

Author: Deepika Haridas    24 Nov 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 6

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:

Copy Code
' Visual Basic
' This accesses the CustomerID column in the first row of
' the Customers table.
Dim s As String
s = dsCustomersOrders1.Customers(0).CustomerID

// 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:

Copy Code
' Visual Basic
Dim s As String
s = CType(dsCustomersOrders1.Tables("Customers").Rows(0).Item("CustomerID"), String)

// 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.

More generally, there are many times when you might create a dataset dynamically without having a schema available. In that case, the dataset is simply a convenient structure in which you can keep information, as long as the data can be represented in a relational way. At the same time, you can take advantage of the dataset's capabilities, such as the ability to serialize the information to pass to another process, or to write out an XML file



Thanks & Regards,
Deepika
Editor

If U want to shine like a SUN..First U have to burn like the SUN!!
Need a Guide? Join my mentor program..



Author: Asal-2009    24 Nov 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 4

hi,
http://www.sellsbrothers.com/askthewonk/secure/Whatsthedifferencebetween.htm
http://www.velocityreviews.com/forums/t94794-difference-between-typed-dataset-and-untyped-dataset.html
http://forums.asp.net/ThreadNavigation.aspx?PostID=2186857&NavType=Next
http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.adonet/2006-12/msg00158.html

i hope this may help u

G.Rajan
Happy New Year



Author: gowthami chowdary    25 Nov 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 5

A typed dataset is a custom class generated for your project by Visual Studio that makes common jobs easier. It adds things like named properties that match column and row data in the tables. It's generated code and not a part of .NET, so you can't use typed datasets without Visual Studio unless you copy all of the code and manually customize it for your project. An untyped dataset is an object of the DataSet class. It's a part of .NET and you can use it even if you don't have Visual Studio.


Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Dynamic connectionstring for XSD Dataset
Previous : Please give the solution for this
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use