Hey :)

How do I load data from a Access DB into a combobox?

Heres my code if anyone is intrested:

Public Class Reparaciones
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents btn_alta As System.Windows.Forms.Button
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents cmb_productos As System.Windows.Forms.ComboBox
    Friend WithEvents txt_unidades As System.Windows.Forms.TextBox
    Friend WithEvents lbl_unidades As System.Windows.Forms.Label
    Friend WithEvents lbl_producto As System.Windows.Forms.Label
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents txt_fecha As System.Windows.Forms.TextBox
    Friend WithEvents cmb_matricula As System.Windows.Forms.ComboBox
    Friend WithEvents txt_horasreparacion As System.Windows.Forms.TextBox
    Friend WithEvents txt_preciohora As System.Windows.Forms.TextBox
    Friend WithEvents txt_dni As System.Windows.Forms.TextBox
    Friend WithEvents lbl_horasrepa As System.Windows.Forms.Label
    Friend WithEvents lbl_preciohora As System.Windows.Forms.Label
    Friend WithEvents lbl_fecha As System.Windows.Forms.Label
    Friend WithEvents lbl_matr As System.Windows.Forms.Label
    Friend WithEvents lbl_dni As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btn_alta = New System.Windows.Forms.Button
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.cmb_productos = New System.Windows.Forms.ComboBox
        Me.txt_unidades = New System.Windows.Forms.TextBox
        Me.lbl_unidades = New System.Windows.Forms.Label
        Me.lbl_producto = New System.Windows.Forms.Label
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.txt_fecha = New System.Windows.Forms.TextBox
        Me.cmb_matricula = New System.Windows.Forms.ComboBox
        Me.txt_horasreparacion = New System.Windows.Forms.TextBox
        Me.txt_preciohora = New System.Windows.Forms.TextBox
        Me.txt_dni = New System.Windows.Forms.TextBox
        Me.lbl_horasrepa = New System.Windows.Forms.Label
        Me.lbl_preciohora = New System.Windows.Forms.Label
        Me.lbl_fecha = New System.Windows.Forms.Label
        Me.lbl_matr = New System.Windows.Forms.Label
        Me.lbl_dni = New System.Windows.Forms.Label
        Me.GroupBox1.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.SuspendLayout()
        '
        'btn_alta
        '
        Me.btn_alta.Location = New System.Drawing.Point(168, 336)
        Me.btn_alta.Name = "btn_alta"
        Me.btn_alta.Size = New System.Drawing.Size(112, 24)
        Me.btn_alta.TabIndex = 14
        Me.btn_alta.Text = "Alta Reparación"
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.cmb_productos)
        Me.GroupBox1.Controls.Add(Me.txt_unidades)
        Me.GroupBox1.Controls.Add(Me.lbl_unidades)
        Me.GroupBox1.Controls.Add(Me.lbl_producto)
        Me.GroupBox1.Location = New System.Drawing.Point(24, 208)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(472, 104)
        Me.GroupBox1.TabIndex = 20
        Me.GroupBox1.TabStop = False
        '
        'cmb_productos
        '
        Me.cmb_productos.Location = New System.Drawing.Point(96, 64)
        Me.cmb_productos.Name = "cmb_productos"
        Me.cmb_productos.Size = New System.Drawing.Size(104, 21)
        Me.cmb_productos.TabIndex = 17
        '
        'txt_unidades
        '
        Me.txt_unidades.Location = New System.Drawing.Point(256, 64)
        Me.txt_unidades.Name = "txt_unidades"
        Me.txt_unidades.Size = New System.Drawing.Size(80, 20)
        Me.txt_unidades.TabIndex = 16
        Me.txt_unidades.Text = ""
        '
        'lbl_unidades
        '
        Me.lbl_unidades.Location = New System.Drawing.Point(256, 32)
        Me.lbl_unidades.Name = "lbl_unidades"
        Me.lbl_unidades.Size = New System.Drawing.Size(88, 24)
        Me.lbl_unidades.TabIndex = 15
        Me.lbl_unidades.Text = "Unidades"
        '
        'lbl_producto
        '
        Me.lbl_producto.Location = New System.Drawing.Point(96, 32)
        Me.lbl_producto.Name = "lbl_producto"
        Me.lbl_producto.Size = New System.Drawing.Size(88, 24)
        Me.lbl_producto.TabIndex = 14
        Me.lbl_producto.Text = "Productos"
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.txt_fecha)
        Me.GroupBox2.Controls.Add(Me.cmb_matricula)
        Me.GroupBox2.Controls.Add(Me.txt_horasreparacion)
        Me.GroupBox2.Controls.Add(Me.txt_preciohora)
        Me.GroupBox2.Controls.Add(Me.txt_dni)
        Me.GroupBox2.Controls.Add(Me.lbl_horasrepa)
        Me.GroupBox2.Controls.Add(Me.lbl_preciohora)
        Me.GroupBox2.Controls.Add(Me.lbl_fecha)
        Me.GroupBox2.Controls.Add(Me.lbl_matr)
        Me.GroupBox2.Controls.Add(Me.lbl_dni)
        Me.GroupBox2.Location = New System.Drawing.Point(24, 56)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(472, 144)
        Me.GroupBox2.TabIndex = 21
        Me.GroupBox2.TabStop = False
        '
        'txt_fecha
        '
        Me.txt_fecha.Location = New System.Drawing.Point(352, 32)
        Me.txt_fecha.Name = "txt_fecha"
        Me.txt_fecha.Size = New System.Drawing.Size(80, 20)
        Me.txt_fecha.TabIndex = 29
        Me.txt_fecha.Text = ""
        '
        'cmb_matricula
        '
        Me.cmb_matricula.Location = New System.Drawing.Point(148, 88)
        Me.cmb_matricula.Name = "cmb_matricula"
        Me.cmb_matricula.Size = New System.Drawing.Size(88, 21)
        Me.cmb_matricula.TabIndex = 28
        '
        'txt_horasreparacion
        '
        Me.txt_horasreparacion.Location = New System.Drawing.Point(148, 56)
        Me.txt_horasreparacion.Name = "txt_horasreparacion"
        Me.txt_horasreparacion.Size = New System.Drawing.Size(80, 20)
        Me.txt_horasreparacion.TabIndex = 27
        Me.txt_horasreparacion.Text = ""
        '
        'txt_preciohora
        '
        Me.txt_preciohora.Location = New System.Drawing.Point(352, 72)
        Me.txt_preciohora.Name = "txt_preciohora"
        Me.txt_preciohora.Size = New System.Drawing.Size(80, 20)
        Me.txt_preciohora.TabIndex = 26
        Me.txt_preciohora.Text = ""
        '
        'txt_dni
        '
        Me.txt_dni.Location = New System.Drawing.Point(148, 32)
        Me.txt_dni.Name = "txt_dni"
        Me.txt_dni.Size = New System.Drawing.Size(80, 20)
        Me.txt_dni.TabIndex = 25
        Me.txt_dni.Text = ""
        '
        'lbl_horasrepa
        '
        Me.lbl_horasrepa.Location = New System.Drawing.Point(36, 56)
        Me.lbl_horasrepa.Name = "lbl_horasrepa"
        Me.lbl_horasrepa.Size = New System.Drawing.Size(104, 24)
        Me.lbl_horasrepa.TabIndex = 24
        Me.lbl_horasrepa.Text = "Horas reparación"
        '
        'lbl_preciohora
        '
        Me.lbl_preciohora.Location = New System.Drawing.Point(260, 72)
        Me.lbl_preciohora.Name = "lbl_preciohora"
        Me.lbl_preciohora.Size = New System.Drawing.Size(88, 24)
        Me.lbl_preciohora.TabIndex = 23
        Me.lbl_preciohora.Text = "Precio Hora"
        '
        'lbl_fecha
        '
        Me.lbl_fecha.Location = New System.Drawing.Point(268, 32)
        Me.lbl_fecha.Name = "lbl_fecha"
        Me.lbl_fecha.Size = New System.Drawing.Size(88, 24)
        Me.lbl_fecha.TabIndex = 22
        Me.lbl_fecha.Text = "Fecha"
        '
        'lbl_matr
        '
        Me.lbl_matr.Location = New System.Drawing.Point(36, 88)
        Me.lbl_matr.Name = "lbl_matr"
        Me.lbl_matr.Size = New System.Drawing.Size(100, 24)
        Me.lbl_matr.TabIndex = 21
        Me.lbl_matr.Text = "Matrícula vehículo"
        '
        'lbl_dni
        '
        Me.lbl_dni.Location = New System.Drawing.Point(36, 32)
        Me.lbl_dni.Name = "lbl_dni"
        Me.lbl_dni.Size = New System.Drawing.Size(88, 24)
        Me.lbl_dni.TabIndex = 20
        Me.lbl_dni.Text = "DNI"
        '
        'Reparaciones
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(520, 478)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.btn_alta)
        Me.Name = "Reparaciones"
        Me.Text = "Reparaciones"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

  
    Private Sub Reparaciones_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim command As New OleDb.OleDbCommand
        Dim conexion As New OleDb.OleDbConnection



        abrir_bd()
        commando()
        commando("select descripcion from producto")






    End Sub

    Private Sub btn_alta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_alta.Click


        abrir_bd()



    End Sub
End Class

Here is the module that I use:

Module Module1


    Public cadena_conexion As String = "provider=microsoft.jet.oledb.4.0;data source=" & Application.StartupPath & "\coches.mdb"
    Public conexion As OleDb.OleDbConnection
    Public comando As OleDb.OleDbCommand

    Public dtr As OleDb.OleDbDataReader


    Public Sub abrir_bd()

        conexion = New OleDb.OleDbConnection(cadena_conexion)
        If conexion.State = ConnectionState.Closed Then conexion.Open()
    End Sub

    Public Sub cerrar_bd()

        If conexion.State = ConnectionState.Open Then conexion.Close()
        conexion = Nothing
        comando = Nothing
    End Sub

End Module

I need help ASAP and urgent.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.