473,473 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

One C# Data Grid View displaying on multiple queries input

1 New Member
I have created a generic method which would take the _query string, obj of datagridview, tablename, obj of dataset_ as shown below


Expand|Select|Wrap|Line Numbers
  1. private void data(string dgvq, DataGridView dgvw, string sTableNm, DataSet dgset)
  2.         {
  3.             createconn();
  4.             dgset.Clear();
  5.             dAdapter = objADOUI.GetDataAdapter(dgvq, myConn);
  6.             dAdapter.Fill(dgset);
  7.             dgvw.DataSource = dgset.Tables[0].DefaultView;
  8.             this.myConn.Close();
  9.         }
  10.  

I am calling this method on different buttons as the are clicked, by passing different parameters. shown below is an example of how its being called.

Expand|Select|Wrap|Line Numbers
  1.         DataSet dset1 = objADOUI.GetDataSet();
  2.         data(Qdgv, dgvDpnl, "TStudent", dset1);
Now, the problem is, Its displaying for once, I mean- When `button1` is clicked its displaying the appropriate results.

But,when `button2` is clicked which has parameters as followed,

Expand|Select|Wrap|Line Numbers
  1.         DataSet dset2 = objADOUI.GetDataSet();
  2.         data(Qdgv, dgvDpnl, "TStudent", dset2);
its creating an exception: <br/>
`"At most one record can be returned by this subquery"` at `data(definition)>dAdapter.Fill(dgset);`

**Note:**
Let me tell u the problem is not with the query, since `button1` is also passing the query which has _sub-queries_ too.

I am aware that the problem is about `unloading` the resources in `datagridview`, `dataset` and `reloading` it.
But, I have tried a lot and couldn't find the solution.

Any help would be appreciated.
Jan 8 '13 #1
2 3277
Frinavale
9,735 Recognized Expert Moderator Expert
Your C# code looks fine so I did a bit of research on the web and it looks like this exception is thrown the SQL syntax is not accepted by the database.

-Frinny
Jan 8 '13 #2
Rabbit
12,516 Recognized Expert Moderator MVP
Looks that way to me too. The issue is the query. It's not that you're using subqueries that's causing the issue. It's that the subquery is returning more than one row. Depending on how it's being used, subqueries can be limited to only one row.
Jan 8 '13 #3

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

Similar topics

2
by: Joe Griffith | last post by:
I'm using a Win Forms Data Grid View control in unbound mode. When I add columns using the wizard the first item is the column name. Everything works fine. However, if you return to the...
0
by: Gian Paolo | last post by:
this is something really i can't find a reason. I have a form with a tabcontrol with tree pages, in the second page there is a Data GRid View. Plus i have a class. When i open the form i...
2
by: Dilanka | last post by:
I want to double click on the particular data item in data grid view and get that those values to another form can somebody tell me how can i do this? i'm using visual studio .net 2005 and the...
0
by: nanaalwi | last post by:
hi there, im doing a project right now to download a data from EEPROM of a camcorder. i used a 'data grid view' to display all the data downloaded from the camcorder. however, i have to save the...
1
by: dineshsanduke | last post by:
hi i m new user i created programatic data grid. i want numeric cell validation in data grid view
1
by: Jerry | last post by:
Hi I have a data grid view that I have AllowUserToResizeColumns = True but at runtime, the user cannot resize columns. Is there something I am missing? Is there a conflict with the ability to...
1
by: mehdi1727 | last post by:
How Can I Print a Data Grid View in C#.net
2
by: jakeesgirl | last post by:
I'm creating a C# program in Visual Studio. When I query the sql database, the results are put into a data grid view. However, the column widths are always too small when displayed. I have text that...
0
by: vimal.424 | last post by:
hello all plz tell me how can we retrieve data from dropdowm box in Data Grid view Thanks in advance
0
by: cadab | last post by:
I have a data grid view, i have specified several columns through the designer that i would like to show on the grid, i have mapped them to the datasource, this works fine, the problem is, my data...
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
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,...
0
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...
1
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
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,...
0
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...
0
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.