Click here to Skip to main content
15,063,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am exporting excel to gridview but problem is

he Microsoft Office Access database engine could not find the object 'Products$'. Make sure the object exists and that you spell its name and the path name correctly.

my code is

Protected Sub btnImport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnImport.Click
        Dim connString As String = ""
        Dim strFileType As String = Path.GetExtension(fileuploadExcel.FileName).ToLower()
        Dim path__1 As String = fileuploadExcel.PostedFile.FileName
        'Connection String to Excel Workbook
        If strFileType.Trim() = ".xls" Then
            connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path__1 & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=2"""
        ElseIf strFileType.Trim() = ".xlsx" Then
            connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & path__1 & ";Extended Properties=""Excel 12.0;HDR=Yes;IMEX=2"""
        End If
        Dim query As String = "SELECT SLNo,TagName,Description,Remarks FROM [Products$]"
        Dim conn As New OleDbConnection(connString)
        If conn.State = ConnectionState.Closed Then
        End If
        Dim cmd As New OleDbCommand(query, conn)
        Dim da As New OleDbDataAdapter(cmd)
        Dim ds As New DataSet()
        grvExcelData.DataSource = ds.Tables(0)
    End Sub

And my excel sheet name is Products$

can any help regarding this

1 solution

Import/Upload Excel Data to Gridview in C#, VB.NET[^]

You need to mention sheet name from which you're trying to get records.

Make sure if your sheet name is Products$
Make sure if file exist on location
Manohar_manu 19-Jun-13 5:18am
yes i ve referred from same website
i am cheking from breakpoint but same error coming
yes it is going else if condition in my code
Same name i have given as excel
Prasad_Kulkarni 19-Jun-13 5:19am
Try to debug your code. Hope you get some more details, and let me know

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