1 Replies - 496 Views - Last Post: 17 January 2013 - 07:54 AM Rate Topic: -----

#1 LeoFazol  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 07-January 13

populate data to a combobox in vb from a access database

Posted 17 January 2013 - 05:26 AM

Hi there,
I'm new to vb and I need to a thing. I've made a simple form by using vb.net. There I entered a combobox and I connected it to a access database. But when I'm running the program, when I click the drop down mark I won't get the details from the connected database. Can somebody tell me what's the wrong with my code?
here is the code
Imports System.Data
Public Class Form1
    Dim inc As Integer
    Dim MaxRows As Integer

    Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim da As OleDb.OleDbDataAdapter
    Dim sql As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con.ConnectionString = "PROVIDER = Microsoft.ace.oledb.12.0;data source = ItemList.accdb"
        con.Open()

        sql = "SELECT * FROM Item_List"
        da = New OleDb.OleDbDataAdapter(sql, con)

        da.Fill(ds, "ItemList")
        con.Close()

        MaxRows = ds.Tables("ItemList").Rows.Count
        inc = -1

    End Sub


End Class



My vb version is vb 2005 express edition.

Is This A Good Question/Topic? 0
  • +

Replies To: populate data to a combobox in vb from a access database

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8955
  • View blog
  • Posts: 33,571
  • Joined: 12-June 08

Re: populate data to a combobox in vb from a access database

Posted 17 January 2013 - 07:54 AM

Quote

when I click the drop down mark I won't get the details from the connected database.

Where is your event handler for this action? I don't see it. I also don't see a second SQL SELECT statement that uses a WHERE clause limiting the 'get' by what ever is in this drop down.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1