Fill DataSet tables from one SPROC

R

Raterus

Hello,

I have a Typed DataSet added to my VS.net Project. This DataSet has two tables I'm interested in filling. I'd like to know if it is possible to fill both tables from one SqlDataAdapter.Fill() call. My stored procedure returns two resultsets. How would map the resultsets returned from the sproc to the correct tables in the DataSet?

Thanks,
--Michael
 
G

Guest

when fill a dataset using adapter, you will get table names like Table,
Table1 etc.
For example, if you want the first table name should be UserDetail second is
countrydetails
you can do it using DataTableMapping collection.
for mapping the column names, you need to use DataColumnMapping collection.

Right now i dont have small example on this. you can explore more on this
direction using this pointer.
 
R

Raterus

Thanks! I was able to get it working properly. Like you said, the tables coming from the sproc were named "Table, Table1, Table2", so to get the mappings set up I had to do this before I called .Fill().

myDataAdapter.TableMappings.Add(new DataTableMapping("Table", "someTableInDataSet"))
myDataAdapter.TableMappings.Add(new DataTableMapping("Table1", "anotherTableInDataSet"))
 

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