I have a SP with 20 select queries. Each query is table-name-aliased like below.
Create procedure sp_get_all_lists
as
begin
select col1, col2 from tb_ nm as name
select col1, col2 from tb_ctry as country
select col1, col2 from tc_cty city
.
.
.
select col1, col2 from tb_prfl as profile
end
I need to bind all the data to dropdown lists in ASP.NET C# web page. While binding, if the query is executed, the DataTable array in DataSet, h开发者_运维百科ave the names as Table1, Table2... etc. I need the datatables to bear the alias names i gave in the SP.
This would help me bind the dropdowns as
ddCtry.DataSource = ds.Tables["country"];
Currently am doing it as ddCtry.DataSource = ds.Tables[1];
Could someone help me to get the table-alias name in C# code.
Thanks in advance.
There is no way to do this (as of .NET 4.0) See the "Multiple Result sets" sections of: http://msdn.microsoft.com/en-us/library/bh8kx08z.aspx
and also this question: set the result table name in stored procedure
You could try using Linq
精彩评论