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. :)