Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming DataTable in a DataSet using SQL?

Tags:

c#

sql

asp.net

I have built a backend system that allows a user to add multiple content section, widgets etc.

I want to keep the queries to the SQL server to a minimum for performance reasons, this is my current flow:

  1. I check my main table which widgets have been added.
  2. I run through each row and build the 'batch' sql query that gets content from mulitple tables.
  3. Call the completed list of queries.
  4. I populate in a DataSet.

Now for the problem:

The tables will never be in the same order, and I can't find a way to name the returned tables.

Is it best to just dedicate a column in each returned DataTable to specify what it actually is, and loop through the DataSet?

Or is there actually a way of naming the returned tables?

like image 321
Marc Uberstein Avatar asked Feb 15 '26 00:02

Marc Uberstein


1 Answers

There is no way to do it automatically, as far as I know. You can give table mappings a try -> http://geekswithblogs.net/dotNETvinz/archive/2009/08/03/why-dataset-creates-tablen-as-the-default-table-name.aspx

like image 55
Mariusz Avatar answered Feb 17 '26 13:02

Mariusz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!