Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to query a query result set in ASP.NET C#

Posted on 2010-08-27
5
Medium Priority
?
507 Views
Last Modified: 2012-05-10
I have a dataset result from a query that I am querying to get counts for a webpage.  I am getting an error referencing the ds.  What is the proper way to reference a ds from a query?

here is my code:

SqlDataAdapter da = new SqlDataAdapter(strSQL,con);
da.Fill(ds,"FlagCnts"); // Flag counts of Surveys completed
                              
// count of total flags for records for Surveys completed  by form
strSQL = "SELECT Form, Sum(A_Flag) AS SumOfA_Flag, Sum(L_Flag) AS SumOfL_Flag, Sum(Q_Flag) AS SumOfQ_Flag, Sum(W_Flag) AS SumOfW_Flag, Sum(O_Flag) AS SumOfO_Flag, Sum(D_Flag) AS SumOfD_Flag FROM FlagCnts GROUP BY  Form;";

da = new SqlDataAdapter(strSQL, con);
da.Fill(ds, "TotalFlaggedRecs");

ptslv
0
Comment
Question by:ptslv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 5

Accepted Solution

by:
Akin Delu earned 2000 total points
ID: 33542796
SqlDataAdapter da = new SqlDataAdapter(strSQL,con);
da.Fill(ds,"FlagCnts"); // Flag counts of Surveys completed
int count = da.Table[0].Rows.Count //this will return number of record
0
 
LVL 35

Expert Comment

by:YZlat
ID: 33543326
you can use Select method of a dataset

http://msdn.microsoft.com/en-us/library/t5ce3dyt(vs.71).aspx
0
 
LVL 35

Expert Comment

by:YZlat
ID: 33543342
Another way is to just use DataView to filter data from your DataSet
0
 
LVL 3

Expert Comment

by:ahll
ID: 33570204
Hi,

I'd say you could combine both queries in just one, so you wont need to access the results from the first query within a second one.
Can you post here the actual SQL you are running the first time?
0
 

Author Closing Comment

by:ptslv
ID: 33598385
I was already doing this to a pont.  I was trying to set up another dataset where I did not need to.  Thanks for the assistance.

ptslv
0

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question