Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
''Here is the code for the first list box
VB
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


''Here is the code for the list box that I want to generate Names of members

VB
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
Posted
Updated 1-May-14 9:24am
v2
Comments
[no name] 28-Apr-14 18:43pm    
Just dumping code into a posting is not a question or a description of any kind of a problem.
Kschuler 1-May-14 16:09pm    
Which line are you getting the error on?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900