Is there a way to name the selected tables in a stored procedure to identify them in the DataSet?

5

I have a Store Procedure in SQL Server that projects multiple data. Example:

CREATE PROCEDURE [dbo].[teste_sp]
AS
BEGIN    

  select * from compra
  select * from cliente
  select * from fatura

END

However, when retrieving the DataSet in C #, table names are shown as: "Table1", "Table2" and "Table3".

Is there any way to name these tables dynamically?

    
asked by anonymous 18.12.2015 / 18:02

1 answer

1

You can use sets of datasets or tablemapping

something like this.

SqlDataAdapter da = new SqlDataAdapter(...);
DataSet ds = new DataSet();
DataTableMapping dtm1, dtm2, dtm3;
dtm1 = da.TableMappings.Add("Table", "compra"); 
dtm2 = da.TableMappings.Add("Table1", "cliente");
dtm3 = da.TableMappings.Add("Table2", "fatura");
da.Fill(ds);
    
21.03.2016 / 18:40