Link to home
Start Free TrialLog in
Avatar of logoncom
logoncom

asked on

Combobox filled using datatable fails

I am trying to get a list of items to fill in a combobox.

I call a function and expect a return list.... what is wrong with my code?  
cbbae.DataSource = employeelist("sales")
 
 
 
    Public Shared Function employeelist(ByVal Dept As String)
 
        Dim cbb As ComboBox = New ComboBox
        Dim dt As DataTable = New DataTable
        Using conn As New SqlConnection(myconnectionstring)
            Using cmd As New SqlCommand("APP_GetEmployeeList", conn)
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("@department", Dept)
 
 
                Using da As New SqlDataAdapter(cmd)
 
 
                    da.Fill(dt)
                    With cbb
                        .DataSource = dt
                        .DisplayMember = "repcode"
                    End With
 
 
                End Using
            End Using
        End Using
 
        Return cbb.DisplayMember
 
    End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of logoncom
logoncom

ASKER

Thanks... that helped