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!

Re: Multiple DataTables in Dataset by Cor

Cor
Mon Apr 04 12:39:48 CDT 2005

Vish,

da1.Fill(ds, "mytablename1") /;with C#


I hope this helps,

Cor



Re: Multiple DataTables in Dataset by W

W
Mon Apr 04 12:51:12 CDT 2005

In addition to what Cor mentioned, you can specify TableMappings which can
handle this for you
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatacommondataadapterclasstablemappingstopic.asp

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Vish" <Vish@discussions.microsoft.com> wrote in message
news:7894AB21-C63A-438A-948D-EB4D0D32B23E@microsoft.com...
> 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!



Re: Multiple DataTables in Dataset by Sahil

Sahil
Mon Apr 04 13:37:34 CDT 2005

You will have to do this within ADO.NET. There are three options.

a) Set the TableName property.
b) use tablemappings.
c) Use an overload of fill.

- Sahil Malik [MVP]
http://codebetter.com/blogs/sahil.malik/



"Vish" <Vish@discussions.microsoft.com> wrote in message
news:7894AB21-C63A-438A-948D-EB4D0D32B23E@microsoft.com...
> 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!



Re: Multiple DataTables in Dataset by WJ

WJ
Mon Apr 04 15:58:15 CDT 2005


"Vish" <Vish@discussions.microsoft.com> wrote in message
news:7894AB21-C63A-438A-948D-EB4D0D32B23E@microsoft.com...
> 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





Re: Multiple DataTables in Dataset by WJ

WJ
Mon Apr 04 16:01:10 CDT 2005


"WJ" <JohnWebbs@HotMail.Com> wrote in message
news:e$3vLCVOFHA.524@TK2MSFTNGP09.phx.gbl...
>
> 3. yourSqlDataAdapter.TableMappings.Add("Table2","Customers");

Correction: It should read "Orders", not "Customers" for the last table

John




Re: Multiple DataTables in Dataset by Vish

Vish
Mon Apr 11 11:08:02 CDT 2005

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!

"WJ" wrote:

>
> "WJ" <JohnWebbs@HotMail.Com> wrote in message
> news:e$3vLCVOFHA.524@TK2MSFTNGP09.phx.gbl...
> >
> > 3. yourSqlDataAdapter.TableMappings.Add("Table2","Customers");
>
> Correction: It should read "Orders", not "Customers" for the last table
>
> John
>
>
>
>

Re: Multiple DataTables in Dataset by Marc

Marc
Tue Apr 12 01:09:24 CDT 2005

>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

Re: Multiple DataTables in Dataset by Sahil

Sahil
Wed Apr 13 08:29:52 CDT 2005

You can't name datatables in stored procs.

- Sahil Malik [MVP]
http://codebetter.com/blogs/sahil.malik/


"Vish" <Vish@discussions.microsoft.com> wrote in message
news:369CBC3B-BFD2-424D-A8B4-782879949D82@microsoft.com...
>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!
>
> "WJ" wrote:
>
>>
>> "WJ" <JohnWebbs@HotMail.Com> wrote in message
>> news:e$3vLCVOFHA.524@TK2MSFTNGP09.phx.gbl...
>> >
>> > 3. yourSqlDataAdapter.TableMappings.Add("Table2","Customers");
>>
>> Correction: It should read "Orders", not "Customers" for the last table
>>
>> John
>>
>>
>>
>>