Do you have two selects in your stored proc?
Also you need to add table mappings...
and Datarelations if any...
Check out :
http://support.microsoft.c
http://www.eggheadcafe.com
Main Topics
Browse All TopicsHello experts,
I am fairly new to VB.NET and I am faced with the following problem:
I am trying to populate two tables in a dataset using a stored procedure. The tables are unrelated and the stored procedure has two separate select statements. When executing the stored procedure in SQL Server Management studio I can see two separate tables.
The dataset as defined in the VB.NET .xsd file has two table definitions.
My issue is that only the first table gets populated. How can I use the same SqlDataAdapter.
Here is how the FillDataSet subroutine looks like
Protected Sub FillDataset(ByVal commandText As String, ByVal dataSet As DataSet, ByVal tableNames As String())
try
Dim sqlCommand As sqlCommand = New sqlCommand(commandText, _conn)
sqlCommand.CommandType = CommandType.StoredProcedur
_da = New SqlDataAdapter(sqlCommand)
'If I just call only the first table is filled.
_da.Fill(dataSet, tableNames(0)
'If I just pass the dataSet
_da.MissingSchemaAction = MissingSchemaAction.AddWit
_da.Fill(dataSet)
'I also tried to loop through the tables
for iTableCount = 0 to tableNames.Length - 1
_da.Fill(dataSet.Tables(iT
Next
' I also tried adding tableMappings but still not success.
I try to determine if both tables were filled the following way:
ds.Table1.Rows.Count > 0
ds.Table2.Rows.Count = 0 ' Meaning that the table is empty.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Do you have two selects in your stored proc?
Also you need to add table mappings...
and Datarelations if any...
Check out :
http://support.microsoft.c
http://www.eggheadcafe.com
cyman73,
AFAIK, the syntax should be just to pass the dataset variable and the tables and associated names will automatically be created for you. The first will be "Table" and the second "Table1". If you pass with a tablename, then first will be "MyTableName"; second, "MyTableName1". This is explained briefly here:
http://msdn.microsoft.com/
For your code, see the snippet for a demonstration of what I am saying should be usage.
Business Accounts
Answer for Membership
by: cyman73Posted on 2009-08-27 at 10:15:12ID: 25200549
The simple question is how to fill dataset using SQLDataAdapter with bach sql statements (stored procedure)
Can anyone help?