Table names in SQL resultsets?

  • Thread starter Thread starter Dave Veeneman
  • Start date Start date
D

Dave Veeneman

I am using a stored procedure to fetch two tables into a DataSet:

ALTER PROCEDURE GetLedgerComponents
AS
SELECT * FROM Ledgers WHERE LedgerStatus = 1
SELECT * FROM LedgerAccounts WHERE LedgerAccountStatus = 1
RETURN

In the DataSet, the tables have the name "Table1" and Table2". I'd like to
specify the names of the DataSet tables, preferably in the stored procedure.
Is there any way to do this, or do I have to rename them by resetting the
TableName
property in the DataSet? Thanks
 
Hi Dave,

I was under impression that the table name would be set from the first
statament in FROM list, but thinking twice it can't be.
So, the only way would be to change the TableName property.
 
Use the TableMappings.Add() method of the DataAdapter:

DataAdapter da = new DataAdapter();
da.TableMappings.Add("Table", "YourFirstTableName");
da.TableMappings.Add("Table1", "YourSecondTableName");

Then, da.Fill(ds) will map the table names.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Back
Top