473,383 Members | 1,748 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,383 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 9246
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.