Hi, everyone!
I want to make search a student's grade. Each student follows the 10 subjects. I want to make a search of students in certain grades. I made 10 textboxs to input the value I want to search. I put a combobox on left of each textbox to select a value more than or less than. Each textbox is set to 0 as the default value. And each of my combobox already set as a minimum value ("<").

Here's what I want to do:
“SELECT * FROM tbStudents WHERE lesson1 > textbox1.text AND lesson2 < textbox2.text AND lesson3 < textbox3.text ,… AND lesson10 > textbox10.text

My trouble is how do I determine the value of the maximum and minimum values for each search
Thank You!
Sorry for my bad english

I used this code in getting max number of records in my database hope you got an idea with this:

 Private Sub mainform_Load(sender As Object, e As EventArgs) Handles MyBase.Load

   cmd.Connection = conn
            cmd.CommandText = "SELECT MAX(ColumnName)  FROM [databaseName].[dbo].[tableName]"
            conn.Open()
            dr = cmd.ExecuteReader()
            Do While dr.Read()
                x.Text = x.Text & dr.GetValue(0) & vbTab
            Loop
            dr.Close()
            conn.Close()

End sub

You can determine the maximum and minimum value of a column by

SELECT minval=MIN(fldname), maxval=MAX(fldname) 
  FROM tablename

and you can simplify your other query by using BETWEEN as in (for example)

SELECT * FROM tbStudents
 WHERE fld1Name BETWEEN 50 AND 100
   AND fld2Name BETWEEN 75 AND  85
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.