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