Is your
LevelNo column of INT data type? If so your SQL statement is incorrect because you are passing in a string , change your SQL statement to
vb
MyCmd.CommandText = "select DISTINCT CourseID from Course where LevelNo=" & g1
Also, I believe you have your sequence out of order, you need to setup your SqlCommand Object before you open your connection, like:
vb
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim g1 As String
ComboBox2.Items.Clear() 'refresh combo sem
g1 = ComboBox1.Text
Dim MyCmd As New OleDbCommand
Dim MyReader As OleDbDataReader
MyCmd.Connection = con
MyCmd.CommandType = CommandType.Text
MyCmd.CommandText = "select DISTINCT CourseID from Course where LevelNo='" & g1 & "'"
con.Open()
MyReader = MyCmd.ExecuteReader
Do While MyReader.Read
ComboBox2.Items.Add(MyReader.GetString("0")) 'this statment select only 1 (0)coulmn in table
Loop
MyReader.Close()
con.Close()
End Sub