Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dataset
Message
 
To
03/11/2002 22:33:50
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Miscellaneous
Thread ID:
00718356
Message ID:
00718407
Views:
19
>What are the advantages of creating a dataset as a class?

When you build a dataset with the designer, the generated class allows you to use strong typing and intellisense.

Consider the following code (with custom DS class)
MyDS ds = new MyDS();  // my custom class
...
foreach (MyDS.OrdersRow row in ds.Orders.Rows) {
    row.CustomerID = cusID;
    row.OrderState = 1; // 1=Pending
    }
with this one (generic DataSet)
DataSet ds = new DataSet();
...
foreach (DataRow row in ds.Tables["Orders"].Rows) {
    row["CustomerId"] = cusID; // undetected error here! field name 
is "CustomerID"
    row["OrderType"] = "Pending";    // wrong type
    }
Not only the first option is easier to type (intellisense avoids the need to remember each table/column name) but it's also safer: the compiler will check the existence and type of each member.

Regards,
------------------
Jose Marcenaro
Tercer Planeta - Argentina
http://www.tercerplaneta.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform