Start New Discussion within our Software Development Community

Untitled58 it works tnx but when i click the message box the attach image that shows the problem occurs

U can use Debug.Print("text: "+ text) to check the value...if u dont know how to use debugger

it will show the value of the word declared as a variable but it should be string else convert it to String...

Try this below code...

  Private Sub ComboBox3_SelectedIndexChanged(sender As System.Object, e As System.EventArgs)

con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")

Dim ewaaa As String = "SELECT * FROM Schedulings WHERE YearLevels = '" & ComboBox3.SelectedItem.ToString() & "' AND Sections = '" & ComboBox1.SelectedItem.ToString() & "'"
com = New OleDbCommand(ewaaa, con)
rid = com.ExecuteReader()
    If rid.Read = True Then
       MsgBox("Section Already Exist", MsgBoxStyle.Critical, "Error");
       MsgBox("Section does not Exist", MsgBoxStyle.Critical, "Error");
    End If
End Sub

instead of & use + sign.....if still it does not work then try to convert SelectedItem.ToString to Text....hope it works for u...

This question has already been answered. Start a new discussion instead.