TableNames with ExecuteDataSet

  • Thread starter Thread starter Prefers Golfing
  • Start date Start date
P

Prefers Golfing

We are using Enterprise Library 3.1 Data Access Aplication Block. We pass a
Common.DbCommand to it's ExecuteDataSet. The DbCommand has parameters
attached and calls a stored procedure.

Several of our methods in our Data Access Layer return Datasets which
contain several, up to 16, tables. We'd like to return the DataSet with the
tables named instead of having to name them after the ExecuteDataSet.

For example:

select id, name, active from employees active_employees where active = 1

select id, name, active from employees inactive_employees where active = 0

would make the following possible:

sting tableName = ds.Tables[0].TableName;
// tableName would equal "active_employees"

without setting the table name with ds.Tables[0].TableName =
"active_employees"

Is this possible?
 
While it's possible (see the GetSchema method of the Connection object), I
doubt if the application block supports it. With SQL Server you can also do
a SELECT from the sysobjects table to get the names of any object in the
database--including the tables.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 
Back
Top