[dba-VB] VB.Net combo

John Colby jwcolby at ColbyConsulting.com
Tue Jan 10 18:12:12 CST 2006

I'm trying to set up a combo in VB programmatically.  The following is what
I am using:

    Function LoadCboService()
        Dim strCnn As String = My.Settings.C2DbConquestConnectionString
        Dim cnn As New SqlConnection(strCnn)
        Dim strSQLService As String = "SELECT * FROM tlkpService"
        Dim cmd As New SqlCommand(strSQLService, cnn)
        Dim adpt As New SqlDataAdapter(cmd)

        Dim Ds As DataSet
        Ds = New DataSet("cboService")
        adpt.Fill(Ds, "cboService")
        cboService.DataSource = Ds.Tables("cboService")
        cboService.DisplayMember =
        cboService.ValueMember =
        Return True
    End Function

The function runs to 

        cboService.DisplayMember =

And fails with:  "null reference exception was unhandled"

I am trying to populate a combo box with two columns of a table, the PK
column, and the "display" or text value column.

What am I doing wrong?

John W. Colby

More information about the dba-VB mailing list