Typed Dataset and its Usages
page 6 of 10
by Satheesh Babu
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 50910/ 162

Constructing Typed Dataset

Add a Typed dataset in Visual Studio as we did above from add new item dialog box. Visual studio 2005 comes with a set of items in the Tool box for constructing the typed dataset. The next sections will discuss how to use the typed dataset as an alternative to C# custom business objects. Below shows those items in Visual Studio 2005 Toolbox.

Figure 12– Visual studio Tool bar

1) Drag a Datatable object from the toolbox.

2) To add a column, right click the table object and click Add>Column. Rename the column as you want.

Figure 13– Add a column

3) To specify datatype, click the properties of the corresponding column and specify it.

So the final typed dataset will look like figure 14.

Figure 14

Using the constructed Typed Dataset:

Filling this typed dataset can be done in the same way as we did above, keeping in mind that the database column name and datatype should match with typed dataset. I will explain how to construct the typed dataset programmatically instead of filling it from the database.

To create a new Products row us the following code.

Listing 7: Create new Prodcuts row

BO.Products.ProductsDataTable prod = new BO.Products.ProductsDataTable();
BO.Products.ProductsRow ProRow = prod.NewProductsRow();

Once we create a typed dataset and compile it, Framework will create all the methods and properties that will help us in using the typed dataset. The above lines of code “NewProductsRow()” function is created by the framework which is the equivalent of “NewRow()” function of the normal datatable.

The following table specifies the usual dataset elements and typed dataset equivalent.

DataSet Element

Equivalent Typed DataSet Element



DataTable methods






DataSet Events


The following code will set the value for the column.

Listing 8

ProRow.ProductName = txtProdName.Text; 

View Entire Article

User Comments

Title: Why good for only very small projects?   
Name: Mark
Date: 2010-11-14 5:14:00 PM
Why are Typed DataSets viable only if our project sizes are really small? How about a hybrid: BOs in the middle and UI tiers; Typed DataSets at the DataLayer side--Resolving data-changes from BOs to DataSets?
Title: I need urgent help plz   
Name: Fadi
Date: 2010-06-13 2:10:47 PM
hi there, i am using typed dataset for my rdlc reports in my winforms app with C#. i m inserting data in database form different forms. the problem is, on run time when i insert data in the database its not updated data in rdlc reports, to get new data in my reports i need to close my app and debug it again to see new data in the reports. Is there any way to forcedly refresh data in my typed dataset on runtime???? Looking forward from your positive response.

Title: developer   
Name: John Jones
Date: 2009-08-27 5:19:58 PM
One point I forgot to mention:
Our main goal is to use the same SQL queries (basic inserts, updates, deletes) in both MS Access and SQL Server. Our app was originally written for Access using the VS designer to generate the queries. After testing these queries, we found that if the ` char was removed and replaced by [ ] brackets, then all the queries would work in both db's.
Title: developer   
Name: john
Date: 2009-08-26 12:46:38 PM
We have a DataSet with Table Adapters built for MSAccess using OLEDB. We are using Visual Studio 2005 and .Net 2.0.

When the designer creates insert, update and delete queries it encloses the table name and field names with a ` (ASCII char 96).
For example:

INSERT INTO `table` (`col1`, `col2`, `col3`) values (....)

Is there a reason for this character? Assuming it's for escape purposes, is there a setting to make Visual Studio use another character, eg "[" or "]"?
Title: sir   
Name: jim
Date: 2008-12-15 8:18:50 PM
where is the method SetUnitPriceNull found - not in this sample

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-12-08 5:16:12 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search