473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

multiple tables within a dataset

i was told that its possible to load more than 1 datatable into a dataset
using a stored procedure

i need to fill 3 combo's on my form
if i had a SQL Stored Proc that had 3 different select statments

SELECT.......
go
SELECT.......
go
SELECT........
go

is it just a case of saying:-
dataAdapt.Fill(dsResultSet)

and it will add 3 tables 0,1,2 with the appropriate data from each select?
or is there more to it?

Nov 21 '05 #1
5 9247
Graig,

As far as I know does a SQL batch procedure not work and do you need 3
seperated dataadapters (and therefore select statements). If that is in a
storedprocedure or just given does not matter, it is just a SQLcommand.

You can than do
da1.fill(ds,table1)
da2.fill(ds,table2)
da3.fill(ds,table3)

Or use the same dataadapter and change the select command (For what I see
not any benefit)

I hope this helps

Cor
i was told that its possible to load more than 1 datatable into a dataset
using a stored procedure

i need to fill 3 combo's on my form
if i had a SQL Stored Proc that had 3 different select statments

SELECT.......
go
SELECT.......
go
SELECT........
go

is it just a case of saying:-
dataAdapt.Fill(dsResultSet)

and it will add 3 tables 0,1,2 with the appropriate data from each select?
or is there more to it?

Nov 21 '05 #2
Graig,

As far as I know does a SQL batch procedure not work and do you need 3
seperated dataadapters (and therefore select statements). If that is in a
storedprocedure or just given does not matter, it is just a SQLcommand.

You can than do
da1.fill(ds,table1)
da2.fill(ds,table2)
da3.fill(ds,table3)

Or use the same dataadapter and change the select command (For what I see
not any benefit)

I hope this helps

Cor
i was told that its possible to load more than 1 datatable into a dataset
using a stored procedure

i need to fill 3 combo's on my form
if i had a SQL Stored Proc that had 3 different select statments

SELECT.......
go
SELECT.......
go
SELECT........
go

is it just a case of saying:-
dataAdapt.Fill(dsResultSet)

and it will add 3 tables 0,1,2 with the appropriate data from each select?
or is there more to it?

Nov 21 '05 #3
"Craig G" <cr**********@yarrasoftware.com> wrote in message
news:eS**************@tk2msftngp13.phx.gbl...
i was told that its possible to load more than 1 datatable into a dataset
using a stored procedure

i need to fill 3 combo's on my form
if i had a SQL Stored Proc that had 3 different select statments

SELECT.......
go
SELECT.......
go
SELECT........
go

is it just a case of saying:-
dataAdapt.Fill(dsResultSet)

and it will add 3 tables 0,1,2 with the appropriate data from each select? or is there more to it?


I have used 1 dataadapter with 1 command & its stored proceedure to fill
multiple datatables in a single dataset with just 1 fill command. However I
only had the go at the very end of the sp, not in the middle.
--
Jonathan Bailey.
Nov 21 '05 #4
JD
Yep thats about it. I created a stored procedure on NorthWind database:

CREATE PROCEDURE TestTables AS
select * from products
select * from categories
Then did the following code:

Dim SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Dim SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Dim SqlConnection1 As System.Data.SqlClient.SqlConnection
SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
SqlConnection1 = New System.Data.SqlClient.SqlConnection
'
'SqlDataAdapter1
'
SqlDataAdapter1.SelectCommand = SqlSelectCommand1
SqlDataAdapter1.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "TestTables", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("ProductID", "ProductID"), New
System.Data.Common.DataColumnMapping("ProductName" , "ProductName"), New
System.Data.Common.DataColumnMapping("SupplierID", "SupplierID"), New
System.Data.Common.DataColumnMapping("CategoryID", "CategoryID"), New
System.Data.Common.DataColumnMapping("QuantityPerU nit", "QuantityPerUnit"),
New System.Data.Common.DataColumnMapping("UnitPrice", "UnitPrice"), New
System.Data.Common.DataColumnMapping("UnitsInStock ", "UnitsInStock"), New
System.Data.Common.DataColumnMapping("UnitsOnOrder ", "UnitsOnOrder"), New
System.Data.Common.DataColumnMapping("ReorderLevel ", "ReorderLevel"), New
System.Data.Common.DataColumnMapping("Discontinued ", "Discontinued")}), New
System.Data.Common.DataTableMapping("Table1", "Table1", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("CategoryID", "CategoryID"), New
System.Data.Common.DataColumnMapping("CategoryName ", "CategoryName"), New
System.Data.Common.DataColumnMapping("Description" , "Description"), New
System.Data.Common.DataColumnMapping("Picture", "Picture")})})
'
'SqlSelectCommand1
'
SqlSelectCommand1.CommandText = "[TestTables]"
SqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure
SqlSelectCommand1.Connection = SqlConnection1
SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE" ,
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
'
'SqlConnection1
'
SqlConnection1.ConnectionString = <<SOME CONNECTION STRING>>

Dim DS As New DataSet
SqlDataAdapter1.Fill(DS)

Worked like a charm.

JD
"Craig G" <cr**********@yarrasoftware.com> wrote in message
news:eS**************@tk2msftngp13.phx.gbl...
i was told that its possible to load more than 1 datatable into a dataset
using a stored procedure

i need to fill 3 combo's on my form
if i had a SQL Stored Proc that had 3 different select statments

SELECT.......
go
SELECT.......
go
SELECT........
go

is it just a case of saying:-
dataAdapt.Fill(dsResultSet)

and it will add 3 tables 0,1,2 with the appropriate data from each select? or is there more to it?

Nov 21 '05 #5
Simply don't use GO between you SELECT statements and Fill will
automatically create multiple tables.

When it finishes you can then name the autonamed tables as you like.

da.Fill(dsResultSet)
dsResultSet.Tables("Table").TableName="MyFirstTabl e"
dsResultSet.Tables("Table1").TableName="MyNextTabl e"
dsResultSet.Tables("Table2").TableName="MyLastTabl e"

Greg

"Craig G" <cr**********@yarrasoftware.com> wrote in message
news:eS**************@tk2msftngp13.phx.gbl...
i was told that its possible to load more than 1 datatable into a dataset
using a stored procedure

i need to fill 3 combo's on my form
if i had a SQL Stored Proc that had 3 different select statments

SELECT.......
go
SELECT.......
go
SELECT........
go

is it just a case of saying:-
dataAdapt.Fill(dsResultSet)

and it will add 3 tables 0,1,2 with the appropriate data from each select?
or is there more to it?

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: | last post by:
Hi, I have an app that uses a typed dataset to persist user data. The dataset has a multiple tables with multiple table relations. The problem I am running into is that the user data is...
1
by: Ahmet Karaca | last post by:
Hi. myds.Reset(); mycommand.SelectCommand.CommandText= "Select att1 from Ing as Ingredient, Pro as Product "+ "where Pro.ad='apple' and Pro.id=Ing.id"; mycommand.Fill(myds, "Product"); // Here...
3
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to...
9
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
1
by: sneha123 | last post by:
There will be some 20 questions and for each question there will be 4 choices.what i want to do is to select multiple answers by clicking the checkbox. i m using asp.net,vb.net pls help me we...
9
by: jaYPee | last post by:
I have search a lot of thread in google newsgroup and read a lot of articles but still i don't know how to update the dataset that has 3 tables. my 3 tables looks like the 3 tables from...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
0
by: Gef.Mongoose | last post by:
Is it possible to access the information from other tables within a dataset when bound to a dataview control? When I bind the dataset in question I only seem to have access to the first table of...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.