Question Limiting Combobox based on Database

kampao00

New member
Joined
Mar 29, 2012
Messages
1
Location
San Mateo, Rizal, Philippines
Programming Experience
1-3
hello ! can you please help me..?


i want to limit the number of students(60) that will be enrolled in one section and prompt a message that it surpass the limit.... i inserted it in my combobox1
..here's my code :




VB.NET:
strsql = "select  * from Schedulings where Sections = '" & ComboBox1.Text & "'"
        Dim acscmd As New OleDb.OleDbCommand


        acscmd.CommandText = strsql
        acscmd.Connection = asconn
        acsdr = acscmd.ExecuteReader()
        TextBox9.Clear()
        TextBox5.Clear()
        ListView1.Items.Clear()
        If acsdr.Read = 2 Then
            MsgBox("To many enrolled in this sections")
        Else


            While (acsdr.Read())
                TextBox9.Text = (acsdr("SectionNames"))
                TextBox5.Text = (acsdr("Adviser"))
                showmyrecords()
            End While
            acscmd.Dispose()
            acsdr.Close()
        End If


it doesnt work. how should i do it?


kindly help me.
 
I'm not shore I understand your question.
You want to limit DB to give you only 60 results, or display only 60, or...?
 
VB.NET:
SELECT COUNT(*) FROM SomeTable WHERE ...
That query will tell you how many records match your specified criteria. Create a command and call ExecuteScalar to get the number. If it's less than 60 then you're good to add another, otherwise you're full.
 
Back
Top