I have a stored procedure that returns multiple tables.
It populates my dataset correctly but it names my tables [Table
,Table1
,Table2
,...].
Is there something I can add in the database layer (to my stored procedure) that will name the tables properly?
Your SP is not actually returning multiple tables, its returning a selection of columns and rows from your tables, therefore there is no 'table name', and hence why they are named table1, table2 etc. If its important, you could return an extra column for each selection, and in that column fill it with the desired name and then use it from there.
i.e.
in stored procedure:
in Vb.Net code:
Kinda SILLY (OR STUPID) that you cannot name tables in a result set. But this gets you there without a HUGE byte count repeating the table name within each row.
There is still overhead passing the NULL value back for each row. Perhaps passing a BIT value would be smaller yet...
And an alternative is to always use column(0): in SQL:
in vb.net:
These methods get your table-names even if the query returns zero rows.
but the best for last... a way to actually name the tables in the dataset automatically, every time FROM SQL STORED PROCEDURE (with help from your code):
After this, you may access your tables with the name YOU control within the stored procedure... as it should have been from day-one!
EDIT: selective implementation: Name the first column in the pattern "TN:Customer". Your legacy stored procedures work normally, only impacting the stored procedures you wish to modify.
... david ...