I have written a single stored procedure that returns 2 tables:
select *
from workers
select *
from orders
I call this stored procedure from my C# application and get a DataSet with two tables, and everything is working fine.
My question is how can I change the tables name at the SQL Server side so that in the C# side I will be able to access it via a name (instead of Tables[0]):
myDataSet.Tables["workers"]...
I tried to look for the answer in Google but couldn’t find it. Maybe the search keywords was not sufficient.
You cannot really do anything from the server-side to influence those table names – those names only exist on the client-side, in your ADO.NET code.
What you can do is on the client-side – add table mappings – something like:
This would “rename” the
Table(first result set) toworkersandTable1(second result set) toordersbefore you actually fill the data. So after the call toyou would then have
myDataSet.Tables["workers"]andmyDataSet.Tables["orders"]available for you to use.