Mahesh
Mahesh

Reputation: 1699

DataSet stored procedure table names

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

Upvotes: 0

Views: 209

Answers (2)

davidWazy
davidWazy

Reputation: 61

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

Upvotes: 0

Jay Riggs
Jay Riggs

Reputation: 53603

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";

Upvotes: 1

Related Questions