Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load myconnection.Open() 'MessageBox.Show("Connection Opened") Dim mycommand As New SqlCommand Dim Ins As String = Login.LgnText.Text Dim section As String = CourseSel.SelectionScreen.Item(1, CourseSel.SelectionScreen.CurrentRow.Index).Value() mycommand.Connection = myconnection mycommand.CommandType = CommandType.StoredProcedure mycommand.CommandText = "StudentGroups" mycommand.Parameters.AddWithValue("Course", CourseSel.Course.SelectedValue) mycommand.Parameters.AddWithValue("Ins", Ins) mycommand.Parameters.AddWithValue("sec", section) 'MessageBox.Show("SQL Statement Executed") Dim adap As New SqlDataAdapter(mycommand) Dim dt As New DataTable adap.Fill(dt) TeamList.DataSource = dt TeamList.DisplayMember = "TeamNumber" TeamList.ValueMember = "TeamNumber" TeamList.SelectedIndex = -1 myconnection.Close() End Sub End Class
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TeamList.SelectedIndexChanged 'MessageBox.Show("Connection Opened") Dim mycommand As New SqlCommand Dim Ins As String = Login.LgnText.Text Dim section As String = CourseSel.SelectionScreen.Item(1, CourseSel.SelectionScreen.CurrentRow.Index).Value() mycommand.Connection = myconnection mycommand.CommandType = CommandType.StoredProcedure mycommand.CommandText = "TeamMembers" mycommand.Parameters.AddWithValue("Course", CourseSel.Course.SelectedValue) mycommand.Parameters.AddWithValue("Ins", Ins) mycommand.Parameters.AddWithValue("sec", section) mycommand.Parameters.AddWithValue("TN", TeamList.SelectedValue) 'MessageBox.Show("SQL Statement Executed") Dim adap1 As New SqlDataAdapter(mycommand) Dim dt As New DataTable Dim ds As New DataSet adap1.Fill(dt) dt = ds.Tables("TeamNumber") TeamList.DataSource = dt TeamList.DisplayMember = "LastName, First Name" TeamList.ValueMember = "LastName" TeamList.SelectedIndex = -1 End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)