• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 509
  • Last Modified:

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

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
ptslv
Asked:
ptslv
1 Solution
 
Akin DeluI’m a software engineer, tech enthusiast and UI/UX lover. Commented:
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
 
YZlatCommented:
you can use Select method of a dataset

http://msdn.microsoft.com/en-us/library/t5ce3dyt(vs.71).aspx
0
 
YZlatCommented:
Another way is to just use DataView to filter data from your DataSet
0
 
ahllCommented:
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
 
ptslvAuthor Commented:
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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now