0

I am calling a stored procedure to return two tables. I am getting it as a dataset in my console application. The table names in the dataset are something like TABLE,TABLE1.

Is there anyway to change this to a meaningful names from stored procedure?

Thanks, Mahesh

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Mahesh
  • 1,651
  • 5
  • 26
  • 47

2 Answers2

1

I don't think you can name DataTables from stored procedures.

Of course it's easy to do this in code. In C# you can do the following, assuming a DataSet dataSet with two DataTables, one named TABLE and the other named TABLE1:

 dataSet.Tables["TABLE"].TableName = "MyBetterTableName";
 dataSet.Tables["TABLE1"].TableName = "AnotherTableName";

and while you're at it, you can name your DataSet:

 dataSet.DataSetName = "MyDataSet";
Jay Riggs
  • 53,046
  • 9
  • 139
  • 151
0

IMO there is ZERO advantage of renaming unless we know we're getting the correct table reference.

The actual need is to know your tables by STRONG-NAMES controlled at the data source.... something to tie a SPECIFIC RESULT table to a NAME controlled by the SOURCE of the data-set.

There is ZERO difference in accessing "Table1" or "AnotherTableName" if the underlying table position has changed; it will still be wrong. If the SPROC returns dynamic results-sets, the position is unpredictable. If the SPROC is changed, even correctly, but positions change, you have a broken system.

I believe that is the root of this question.

And I think I have a very workable solution. check out this answer.

too long to reproduce here

Community
  • 1
  • 1
davidWazy
  • 61
  • 6