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!
**********************************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top