Question:
I have a Store Procedure in SQL Server that projects various 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#, the table names are shown as: "Table1", "Table2" and "Table3".
Is there any way to dynamically name these tables?
Answer:
You can use dataset tablemapping
or datasets
something like.
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);