hi.. i want to compare two tables ..in enlistment table will count the number of students that enlisted to the YearLEvel and section selected by user.. then i want to limit that by means of calling it from the table of Schedulings (AvailableSlots Table)

here's my code but it doesnt work .. it continuosly enlisting students even if it is exceeded in the limit..

con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=|DataDirectory|\Enrollment System.accdb;Jet OLEDB:Database Password=jhedonghae;")
    Dim ewaaa As String = "Select Count(*) as Total from Enlistment  where YearLevels = '" & TextBox4.Text & "' AND  Sections = '" & ComboBox1.Text & "'"
    com = New OleDbCommand(ewaaa, con)
    con.Open()
    'com.ExecuteNonQuery()
    ' rid = com.ExecuteReader
    Dim count As Integer = CInt(com.ExecuteScalar() + 1)
    'rid.Read()
    TextBox3.Text = count

    con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=|DataDirectory|\Enrollment System.accdb;Jet OLEDB:Database Password=jhedonghae;")
    Dim sql As String = "Select * from Schedulings  where YearLevels = '" & TextBox4.Text & "' AND  Sections = '" & ComboBox1.Text & "'"
    com = New OleDbCommand(sql, con)
    con.Open()
    com.ExecuteNonQuery()
    rid = com.ExecuteReader
    rid.Read()
    Try
        ' While rid.Read
        Dim Avail As String = rid.Item(4)
        ' End While

        If rid.Item("AvailableSlots") = True Then
            If count > Avail Then

                MsgBox("Exceeded to the Limit")
                TextBox2.Enabled = False
                TextBox5.Enabled = False
                TextBox9.Enabled = False

                TextBox2.Clear()
                ComboBox1.SelectedIndex = -1
                TextBox5.Clear()
                TextBox6.Clear()
                TextBox4.Clear()
                TextBox1.Clear()
                ListView1.Items.Clear()
            End If
        End If
    Catch
    End Try

I'm confused at what you're actually trying to do:

  1. Count items in a table
  2. Compare two tables
  3. Limit number of enrollees

I'm confused at what you're actually trying to do:

Count items in a table >> count the items that will satisfy the code

Dim ewaaa As String = "Select Count(*) as Total from Enlistment where YearLevels = '" & TextBox4.Text & "' AND Sections = '" & ComboBox1.Text & "'"

Compare two tables >> to limit the number of enlist students that will allow the system from what is set in the schedulings table
Limit number of enrollees > like what isaid .

This article has been dead for over six months. Start a new discussion instead.