473,513 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple resultsets to multiple DataGridView

code green
1,726 Recognized Expert Top Contributor
I am getting three resultsets from a stored procedure
Expand|Select|Wrap|Line Numbers
  1. //Create a DataAdapter, with the name of the stored procedure.
  2. SqlDataAdapter MyAdapter = new SqlDataAdapter("findOrders", myConnection);
  3.  
  4. //Set the command type as StoredProcedure.
  5. MyAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
  6. DataSet DS = new DataSet();
  7.  
I pass a few parameters then try to bind each resultset to three different DataGridView via DataSet and BindingSource.
I can get the first set into the first DataGridView showing Orders
Expand|Select|Wrap|Line Numbers
  1. MyAdapter.Fill(DS,"findOrders");
  2. dbBindSource.DataSource = DS.Tables["findOrders"];
  3. grdOrders.DataSource = dbBindSource;
But when I write the second set to the second DataGridView showing Customers, this also overwrites the first DataGridView with the same data.
Expand|Select|Wrap|Line Numbers
  1. dbBindSource.DataSource = DS.Tables["BB_findOrders1"];
  2. grdCust.DataSource = dbBindSource;
If I try with the third set of Order lines, this overwrites the first and second.
Expand|Select|Wrap|Line Numbers
  1. dbBindSource.DataSource = DS.Tables["BB_findOrders2"];
  2. grdPart.DataSource = dbBindSource
Am I missing a command or doing it completely wrong?
Nov 18 '10 #1
1 2022
code green
1,726 Recognized Expert Top Contributor
Hmm, I'm guessing I need three BindingSource instances....
Nov 18 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2568
by: Top Gun | last post by:
In order to avoid multiple trips to the database, I would like to fill several tables in a DataSet with a single call to a stored procedure that will return resultsets for the appropriate tables. Can the SqlDataReader be used for this?
1
2600
by: Frank Rizzo | last post by:
I have a stored proc that returns 5 resultsets. How can I read each resultset into a separate data reader? Thanks
10
2109
by: Rich Kucera | last post by:
Holding all versions at 5.0.4, Multiple stacks with multiple-version configurations inevitable Will have to wait to see what the impact of problems such as http://bugs.php.net/bug.php?id=33643 to the application world. We may wait for a suitable popular resolution and jump to that version in the future. There's already a rift between PHP4...
0
1290
by: Crazy Cat | last post by:
Hi, Using Visual Basic 2005 -- I have a stored procedure that returns multiple resultsets. I fill a datareader (SQLDataReader to be exact) with the results from a command object's ExecuteReader method and copy the resultset to the datareader by using a DataTable's Load method. However when I execute NextResultset it comes back false and I...
1
2062
by: Robson Siqueira | last post by:
Folks, For designing WinApps, I do prefer to have the controls dragged and dropped into the screen, mainly for datagridview controls. For that end, I normally use the DataSet designer but reading the dataset information from my tables/views/stored procedures. Now I have a case in which I want to use the designer, but with a procedure...
3
3910
by: | last post by:
I'm seeking (probably basic) guidance on the right way to split a large site that's supposed to represent one domain(mydomain.org) into many small VS.NET projects, and how to avoid issues with multiple web.config files leading to the error: "It is an error to use a section registered as allowDefinition = 'MachineToApplication'"... I'm...
6
2846
by: Jankie | last post by:
Hi all ! I hope someone help me with problem that I assume common,yet googling didnt even mention it. In brief: User uploads multiple files at one go. It is one submission of multiple files,so I just need one id record for all those files in mysql.Now I get a corresponding number of ids instead of just one I tried this,but for some reason it...
10
2059
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...
0
1915
by: Camfa | last post by:
Hi all, I’ve been messing around with the following question for 2 days now, and i still haven’t find a fix. So i hope you can help me. I’ll quickly show you guys the situation: There are 2 tables in my database (MainRecords and RecordLines) http://img502.imageshack.us/img502/6106/startscreencv5.png
1
6566
by: sreenu123 | last post by:
How to insert multiple records into a database table that are entered into a datagridview. With a single shot of Save all the records in the datagridview should be updated using C# . Can any one help me in this regard. Please tell me the solution as i have wasted near about whole day on this. I did not find help in google search. Any help...
0
7270
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7125
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...
0
7543
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...
0
4757
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...
0
3252
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...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
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...

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.