Finding Min and Max value of Column in Dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code that executes a parameterized Query and pupulates the data in a datagrid. All is good. My problem is I would now like to get the minimum and maximum value of one of the columns. My code that works is:

public void button2_Click(object sender, System.EventArgs e)
{
dataSet21.Clear();
this.oleDbSelectCommand2.Parameters["StartKey"].Value = textBox2.Text;
int myEndKey = int.Parse(textBox2.Text);
this.oleDbSelectCommand2.Parameters["EndKey"].Value = myEndKey + 64;
oleDbDataAdapter2.Fill(dataSet21);
DataView prodView1 = new DataView(dataSet21.Tables["NDXDailyImport"]);
 
Dan:

The DataTable.Compute method supports Expressions and I'm 99% sure Max and
Min are supported. Typically, it'd be something like
MyDataTable.Comupte("MAX(ColumnValue)", "ColumnValue >= 0")
Dan said:
I have the following code that executes a parameterized Query and
pupulates the data in a datagrid. All is good. My problem is I would now
like to get the minimum and maximum value of one of the columns. My code
that works is:
public void button2_Click(object sender, System.EventArgs e)
{
dataSet21.Clear();
this.oleDbSelectCommand2.Parameters["StartKey"].Value = textBox2.Text;
int myEndKey = int.Parse(textBox2.Text);
this.oleDbSelectCommand2.Parameters["EndKey"].Value = myEndKey + 64;
oleDbDataAdapter2.Fill(dataSet21);
DataView prodView1 = new DataView(dataSet21.Tables["NDXDailyImport"]);
 
Back
Top