?
Solved

Populate Listbox using excel spreadsheet column VB.net

Posted on 2013-11-04
4
Medium Priority
?
980 Views
Last Modified: 2013-11-20
Good Afternoon,

I'm trying to populate a listbox in VB.net using a excel spreadsheet column. In my code below it gives me an error saying the 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine"

Imports System.Data.OleDb
Imports System.Data
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        OpenFileDialog1.Title = "Please Select a File"
        OpenFileDialog1.FileName = ""
        OpenFileDialog1.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
        OpenFileDialog1.ShowDialog()

        Try
            Dim MyConnection As System.Data.OleDb.OleDbConnection
            Dim DtSet As System.Data.DataSet
            Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
            MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source='" & OpenFileDialog1.FileName & "';" & "Extended Properties=""Excel 12.0;HDR=YES;""")
            MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [SEA$A:A]", MyConnection)
            MyCommand.TableMappings.Add("Table", "TestTable")

            DtSet = New System.Data.DataSet
            MyCommand.Fill(DtSet)
            ComboBox1.DataSource = DtSet.Tables("TEAML")


            MyConnection.Close()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

End Class

Open in new window


Error
0
Comment
Question by:AnthonySmithMCP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 18

Expert Comment

by:lludden
ID: 39622684
If you don't have access installed, download and install the runtime version.  It will install the driver for you.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 39623148
could it be related to 32/64 bits?

give a try to the free LINQ-to-Excel tool : http://emoreau.com/Entries/Articles/2013/07/A-free-LINQ-to-Excel-and-CSV-provider.aspx
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 39623871
Download and install ACE driver and then change your connection string to use ACE driver instead of JET

http://www.microsoft.com/en-gb/download/details.aspx?id=13255
0
 
LVL 1

Author Comment

by:AnthonySmithMCP
ID: 39662264
Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question