i need to compare two different tables which are Enlistment and Schedulings Table .
in schedulings Table , there was a columnnmae AvailableSlots wherein the AvailableSlots in every sections in every year is recorded..
in Enlistment table, i used to count the number of records that satisfy my query :

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

Now, i need to know how many slots are taken that satisfies the query.. to know the number of students that can only be enrolled on that particular sections ..

here's my codes :

    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()


    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

     Dim Avail As String = rid.Item(4) ' on this part the debugging stops and says "NO DATA EXIST ON COLUMN/TABLE"                'but i checked it all over again .. it have datas 


        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

please help me. :)

Recommended Answers

All 3 Replies

I have seen ur lots of similar posts. How do u work on project? Do u start directly implementing? Do u implement it at low scale and check if its working?
If not would suggest u to try this way. It will save ur lot of debugging time. Good Luck with ur Project :)

Dim Avail As String = rid.Item(4)
what is Item(4) ...u shud write

Dim Avail As String=rid("columname") and check

yeah it works.. but how to compare the two table?
Counts the number of rows in Enlistment table that satisfies the query.. from the number that save from Schedulings Table.. pls help me..

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.