My code below gathers the total number of samples from tbl_Sample_Login_table between a set of dates. That's nice for a total of all samles - however what I need to do is group by ProductName - capture that product name - and get the total count of that product... continuing on for all different products. This is for making a summary report for all products within the date range. I have been unable to find in searches how to get to my end goal of the report. I'm using VS2019.
Any constructive guidance?
Thanks.
Getting group by and count from dataset:
using (OleDbConnection dbConnection = new OleDbConnection(GlobalVar.networkConnectionString))
{
// CREATE THE COMMAND AND PARAMETER OBJECTS.
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
OleDbCommand cmd;
cmd = new OleDbCommand("SELECT ProductName FROM tbl_Sample_Login_table WHERE LoginDate BETWEEN @startingDate AND @endingDate ORDER BY ProductName", dbConnection);
cmd.Parameters.AddWithValue("@startingDate", startingDate);
cmd.Parameters.AddWithValue("@endingDate", endingDate);
dbConnection.Open();
dataAdapter.SelectCommand = cmd;
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "tbl_Sample_Login_table");
int recordCount;
recordCount = ds.Tables[0].Rows.Count;
Any constructive guidance?
Thanks.