Multiple DataTables in Dataset

G

Guest

Hi,

I am returning multiple datatables from a stored procedure into a dataset.
It keeps naming the datatables as "Table","Table1","Table2" etc. Is there a
way i can change the sproc so that my datatables get created with a name ?
The multiple select statements have multiple joins too so i am not sure where
to alias it. I do not want to depend on the indexes to grab the right tables.
Let me know if there's a solution.

Thanks!
 
W

WJ

Vish said:
It keeps naming the datatables as "Table","Table1","Table2" etc. Is there
a
way i can change the sproc

You do not need to to change your sProc, leave it the way it is. Just map
the default DataAdapter table names ("Table","Table1","Table2") to the order
that your sProc is retrieving data now.

Example: If your sProc reads three tables from Northwind DB as Employees,
Customers, and Orders tables (in that order), then in your code behind, do
the mappings as shown below:

1. yourSqlDataAdapter.TableMappings.Add("Table","Employees");
2. yourSqlDataAdapter.TableMappings.Add("Table1","Customers");
3. yourSqlDataAdapter.TableMappings.Add("Table2","Customers");
4. Call the fill method as: yourSqlDataAdapter.Fill(yourDataset);

John
 
G

Guest

I knew how to do this but the question is whether it can be done in the sproc
? This code depends on the ado.net knowing what sequence is going to come
back for the datatables and if it already knows then i am fine using the
original names as it is. What i want is without assuming the indexes return a
name from the sproc.
Thanks!
 
M

Marc Scheuner [MVP ADSI]

I knew how to do this but the question is whether it can be done in the sproc

No. This naming behaviour is a thing of your ADO.NET client code - no
way for the sproc to specify that.

Marc
================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
 

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

Top