Reputation: 13695
I am using a stored procedure to fill a DataSet. What I need to do is force the name of the DataTable that is created when filled. There are multiple tables returned from the Stored Procedure. The last table is the one I need to make sure has a specific name when returned. It is created by returning a value of a variable and not pulling from any tables.
SELECT @Phone as My_800Number
How can I make this return as table called "D1Header"?
Upvotes: 1
Views: 4405
Reputation: 18013
There is no ADO.NET Native way to do it; ADO.Net assign a generated name with a sequence number, according to this
You can workaround it... if you say you need the last table with a specific name, you can do:
if (ds.Tables.Count > 0) {
ds.Tables[ds.Tables.Count - 1].TableName = "name";
}
Upvotes: 3
Reputation: 13702
Could use an enum of the table names and reference that in your table reference rather than the table itself.
ds.tables(myEnum.Contacts).rows ?
Upvotes: -1