bind a combo by coding

  • Thread starter Thread starter NewsGroup de Microsoft
  • Start date 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"
 
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
 
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
 
Back
Top