Click here to Skip to main content
13,193,064 members (83,134 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi there,
I'm new to vb and I need to know a thing. I've made a simple form by using 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"

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

da.Fill(ds, "ItemList")

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

End Sub

End Class

My vb version is vb 2005 express edition.
Posted 17-Jan-13 1:32am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try this :

Imports System.Data.OleDb
Public Class homemain
    Dim cnn As New OleDbConnection(<connection string="">)
    Dim cmd As New OleDbCommand
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)handles Button1.Click
     cmd.CommandText="select empname from employee"
     Dim dr As OleDbDataReader=cmd.ExecuteReader
     While dr.Read
     End While
End Sub
End Class

Hope, This will help you.
CrugerBrent 17-Jan-13 9:54am
Thanks jenitshah..............................
Ramya Chandran 11-Dec-15 10:57am

I am doing translator program how to write the program for english to tamil translation coding. how will you start the procedure for that program.
I am using front end and back end ms access and using combo box populate the data from database. give some suggestion

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171017.2 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100