[dba-VB] VB.Net combo

John Colby jwcolby at ColbyConsulting.com
Tue Jan 10 20:34:52 CST 2006


Nope, didn't help (or hurt).  Just no change. 


John W. Colby
www.ColbyConsulting.com 


-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Eric Barro
Sent: Tuesday, January 10, 2006 7:20 PM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] VB.Net combo

John,

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

Eric

-----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)
        cnn.Open()
        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 =
Ds.Tables("cboService").Columns("RA_Rank").ToString
        cboService.ValueMember =
Ds.Tables("cboService").Columns("RA_ID").ToString
        Return True
    End Function

The function runs to 

        cboService.DisplayMember =
Ds.Tables("cboService").Columns("RA_Rank").ToString

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
www.ColbyConsulting.com 


_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com


__________ NOD32 1.1359 (20060110) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com


_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com




More information about the dba-VB mailing list