Click here to Skip to main content
16,017,297 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi, there,

Kindly suggest what I do, because I'm using MS office 2013 version and they are not supported in this code in run time error get from pc error is 'the Microsoft office 2013 is not registered on your local machine'.

Please do needful code and please answer me asap.

What I have tried:

Imports System.Data
Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try

            Dim con As System.Data.OleDb.OleDbConnection
            Dim ds As System.Data.DataSet
            Dim cmd As System.Data.OleDb.OleDbDataAdapter
            Dim path As String
            path = "C:\\Users\\Bhargav Ginoya\\Documents\\Visual Studio 2010\\Projects\\Country Club india ltd\\Book1.xls"
            con = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + "; Extended Properties=Excel 12.0;")
            cmd = New System.Data.OleDb.OleDbDataAdapter("Select * From[ALL MEMBERSHIP DETAIL$]", con)

            ds = New System.Data.DataSet
            cmd.Fill(ds)
            DataGridView1.DataSource = ds.Tables(0)
            con.Close()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click


        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.ACE.OLEDB.12.0;Data Source=C:\\Users\\Bhargav Ginoya\\Documents\\Visual Studio 2010\\Projects\\Country Club india ltd\\Book1.xls; Extended Properties=Excel 12.0;")
            MyCommand = New System.Data.OleDb.OleDbDataAdapter _
                ("select * from [ALL MEMBERSHIP DETAIL$]", MyConnection)
            MyCommand.TableMappings.Add("Table", "TestTable")
            DtSet = New System.Data.DataSet
            MyCommand.Fill(DtSet)
            DataGridView1.DataSource = DtSet.Tables(0)
            MyConnection.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

End Class
Posted
Updated 11-Sep-17 3:03am
Comments
Richard MacCutchan 11-Sep-17 2:22am    
The message is quite clear, you need to install MS Office.

As mentioned in the comments, you need to install Office or find a 3rd party dll that will work without it. I believe you can also use the Open XML SDK, [^]
 
Share this answer
 
I would use a database as database. Just saying.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900