473,769 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Result Sets in a DataSet from DataAdapter ?

Liz

Anyone have any info on how you can fill a DataSet with mutiple result sets
from a SQL batch ? I know with a dataReader you can use the nextResult
method but I'm lost on how you do this with a dataAdapter ....

TIA ..

L
Oct 12 '06 #1
4 10932
You may want to do something like this in C# 2.0:

DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter( "select * from authors;
select * from employee",

ConfigurationMa nager.Connectio nStrings["pubsConnection String"].ConnectionStri ng);
sda.Fill(ds);

gvAuthors.DataS ource = ds.Tables[0]; //gvAuthors = GridView
control
gvAuthors.DataB ind();

gvEmployees.Dat aSource = ds.Tables[1]; //gvEmployees = another
GridView control
gvEmployees.Dat aBind();


On Oct 11, 7:56 pm, "Liz" <l...@tiredofsp am.comwrote:
Anyone have any info on how you can fill a DataSet with mutiple result sets
from a SQL batch ? I know with a dataReader you can use the nextResult
method but I'm lost on how you do this with a dataAdapter ....

TIA ..

L
Oct 12 '06 #2
Hi,

DataAdapter.Fil l will do it for you

From MSDN:
When handling batch SQL statements that return multiple results, the
implementation of FillSchema for the .NET Framework Data Provider for OLE DB
retrieves schema information for only the first result. To retrieve schema
information for multiple results, use Fill with the MissingSchemaAc tion set
to AddWithKey.

So it will create one table per resultset
--
Ignacio Machin
machin AT laceupsolutions .com

"Liz" <li*@tiredofspa m.comwrote in message
news:e8******** ******@TK2MSFTN GP02.phx.gbl...
>
Anyone have any info on how you can fill a DataSet with mutiple result
sets
from a SQL batch ? I know with a dataReader you can use the nextResult
method but I'm lost on how you do this with a dataAdapter ....

TIA ..

L


Oct 12 '06 #3
Liz

"Deepak Khanal" <dk*****@gmail. comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
You may want to do something like this in C# 2.0:

DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter( "select * from authors;
select * from employee",

ConfigurationMa nager.Connectio nStrings["pubsConnection String"].ConnectionStri ng);
sda.Fill(ds);

gvAuthors.DataS ource = ds.Tables[0]; //gvAuthors = GridView
control
gvAuthors.DataB ind();

gvEmployees.Dat aSource = ds.Tables[1]; //gvEmployees = another
GridView control
gvEmployees.Dat aBind();

so simple ... don't know why I didn't try that ... thanks ....

Liz
Oct 12 '06 #4
Liz

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:eX******** ******@TK2MSFTN GP03.phx.gbl...
Hi,

DataAdapter.Fil l will do it for you

From MSDN:
When handling batch SQL statements that return multiple results, the
implementation of FillSchema for the .NET Framework Data Provider for OLE
DB
retrieves schema information for only the first result. To retrieve schema
information for multiple results, use Fill with the MissingSchemaAc tion
set
to AddWithKey.
ok ... I'm still finding my way around with this stuff ... what's the
significance of this part of the picture ?

Liz
Oct 12 '06 #5

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

Similar topics

3
4008
by: Kaveri | last post by:
Currently we use a data adapter and a dataset for fetching data from multiple data source. Once we populate the data from each data source we merge all datasets into a single dataset. Hence if there are 50 data retrieved from 50 different sources, we will have to have 50 adapters and datasets. We need to know if there are any better approach to this solution ?
3
7736
by: Mark Miller | last post by:
I have an sp that outputs multiple xml fragments w/ no root. The sp calls individual sp's to output the correct set of data and each "type" has different fields. ex.: <LEADERBOARD @Type='Rushing'> <LEADER @Carries=''/> </LEADERBOARD> <LEADERBOARD @Type='QBRating'> <LEADER @Rating='' @CompletionPct=''/>
3
13086
by: Tc | last post by:
Hi, I was curious, I am thinking of writing an application that loads a dataset from a database that resides on a server. The question I have is this, if multiple copies of the app will be running at once will there be problems with data updates? The reason I ask is I'm thinking like this: User1 launches the app and the dataset is created from the data in the DB.
1
11583
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 is the problem listbox.DataSource = myds.Tables.DefaultView; // Here again listbox.DataTextField = "invid"; // Here again listbox.DataBind(); mycon.Close()
15
6512
by: AussieRules | last post by:
Hi, I have a need to do two selects against to stored proc's in my SQL db. At the moment, each SP is called and two different dataset are populate. Thats two round trips to the SQL server. I can combine the two SP into one, and have one SP that executes two Select Statements, and effectivly returns two result sets, and I could call this with one trip to the SQL server from my VB app.
9
12989
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 northwind database that has an employees, orders, and order details. the following are the 3 tables in my sql database students schyrsem
4
3754
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 and username, password etc will be exactly the same for each server, the only thing that will change is the server name. Idealy I would like to get the server names from a seperate dataset so there could be any number of servers, allthough in...
2
3922
by: Crash | last post by:
SQL Server 2005 SP1 Standard & Express ..NET 2.0 and ADO.NET C# Hi, I have a stored procedure that returns results from 3 select statements. When I "ExecuteDataset" from C# code the returned dataset has 3 tables named "Table", "Table1", "Table2"...
10
2090
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm using this coding to get 2 resultsets thru datareader and then load them into 2 datatables and bind the datatables to datagridviews. But sdrGrid.NextResult() is returning false for some reason. Is that possible the connection is closed? Dim strConn As String = "Server=localhost;Database=northwind;" + _ "Integrated Security=SSPI" Dim cnnNwind As SqlConnection = New SqlConnection(strConn) Try Dim strSql As String = "select * from...
0
10206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9984
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9851
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7403
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.