Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parent & Child
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Miscellaneous
Thread ID:
00686093
Message ID:
00686308
Views:
45
>>Why wouldn't you use the TableName property of the DataTable to set the name?<

Hmmm ... yes, I guess you could do it that way too. But we sub-class the typed DataSets for other reasons besides this (we use a DataSet Interface so that all our DataSet classes have certain methods on them).

~~Bonnie


>Why wouldn't you use the TableName property of the DataTable to set the name? You could iterate through the DataTables that were created with the fill and rename each one to the appropriate name. You would need to be aware of the order in which the selects were generated to properly name them but that shouldn't be a problem since it will be done in code.
>
>
>MyDataSet.Tables[0].TableName="Customers";
>MyDataSet.Tables[1].TableName="Orders";
>
>
>>Dave,
>>
>>When filling the DataSet *either* way (using multiple SELECT statements in your SqlCommand *or* calling a SP), the tables will be called table, Table1, Table2, etc unless you specify a different name in the Fill(), like this:
>>
>>
>>MyDataAdapter.Fill(MyDataSet, "MyTable");
>>
>>
>>But, even doing it this way, the tables will still be named sequentially: MyTable, MyTable1, MyTable2, etc.
>>
>>What we've done in order to use more meaningful table names is to first generate typed DataSets and then further sub-class them to use different names. Here's an example of what I mean (I'm not putting in all the code, because it's on a different computer and I can't copy/paste to here, but you'll get the gist of it):
>>
>>
>>// This code is in a sub-class of the typed DataSet:
>>
>>public tableDataTable Customer
>>{
>>  get {return this.table;}
>>}
>>
>>public Table1DataTable Orders
>>{
>>  get {return this.Table1};
>>}
>>
>>// etc. for Table2, Table3 ...
>>
>>
>>It looks like a lot of work, but we've written a VFP tool (gotta love VFP's string handling capabilities!!) that will generate stuff to and from the Clipboard, so it's easy enough to just plug it into your sub-class.
>>
>>Hope this gives you some food for thought ...
>>
>>~~Bonnie
>>
>>
>>
>>>Bonnie,
>>>
>>>When the DataSet is filled, do these results just go in as Table1, Table2, etc? Is there anything you do to give the tables different names?
>>>
>>>TIA
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform