[dba-VB] VB.Net combo

Eric Barro ebarro at verizon.net
Tue Jan 10 18:20:05 CST 2006


Shooting in the dark here because I do most of my development on web apps
instead of win32 apps but the syntax should be the same.

cboService.DataSource = Ds.Tables("cboService")

Probably needs to read as...

cboService.DataSource = Ds.Tables("cboService").DefaultView


-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of John Colby
Sent: Tuesday, January 10, 2006 4:12 PM
To: dba-vb at databaseadvisors.com
Subject: [dba-VB] VB.Net combo

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

dba-VB mailing list
dba-VB at databaseadvisors.com

__________ NOD32 1.1359 (20060110) Information __________

This message was checked by NOD32 antivirus system.

More information about the dba-VB mailing list