Fill DataSet tables from one SPROC

  • Thread starter Thread starter Raterus
  • Start date Start date
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
 
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.
 
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"))
 
Back
Top