bind a combo by coding

  • Thread starter NewsGroup de Microsoft
  • Start date
N

NewsGroup de Microsoft

how can i bind by coding with valueMember, displayMember and datasource
properties.

if i do it visually, that's right but if i code it, not.

i do somethin' like that:


Dim gCadenaConexion As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source= " & ObtenRutaAplicacion() & "Datos\Datos.mdb"

Dim conexion As New OleDb.OleDbConnection(gCadenaConexion)

Dim adapter As New OleDb.OleDbDataAdapter("SELECT idPublicoObjetivo,
Descripcion FROM PublicoObjetivo", conexion)

Dim dataset As New DataSet()

conexion.Open()

adapter.Fill(dataset, "tabla")

conexion.Close()

Me.ComboBox1.DataSource = dataset

Me.ComboBox1.DisplayMember = "Descripcion"

Me.ComboBox1.ValueMember = "idPublicoObjetivo"
 
W

William Ryan

Try binding it to "tabla" directly, or DataSet.Tables("tabla") //or
DataSet.Tables(0) where 0 is the index of the table.

This should fix it, but verify that your table "tabla" has rows b/c even if
the binding works, if you don't have any rows, it will look like it isn't
working

HTH,

Bill
 
N

NewsGroup de Microsoft

thanks a lot. i try it now

William Ryan said:
Try binding it to "tabla" directly, or DataSet.Tables("tabla") //or
DataSet.Tables(0) where 0 is the index of the table.

This should fix it, but verify that your table "tabla" has rows b/c even if
the binding works, if you don't have any rows, it will look like it isn't
working

HTH,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top