none
Problem reading a xls file.. RRS feed

  • Question

  • Hello,,,

      I am trying to get the data from xls file in to a datatable

    CODE:

    dim filepath as string = "C:\Users\Testmachine\Desktop\"

    dim filename as string ="myfile.xls"

     Dim pathOnly As String = String.Empty

    pathonly = Path.GetDirectoryName(filepath)

    Using connection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & pathOnly & "\" & filename & ";Extended Properties=""Excel8.0;HDR=YES;IMEX=1""")

     

    I tried removing the HDR and IMEX.. but that didn't work..

    Error I am getting....

    Could not find installable ISAM.

     

    Appreciate the Help..

    Thanks

    Wednesday, May 11, 2011 2:19 AM

Answers

  • Are you running 64-bit Windows? If so, change the Platform option to x86 (Build...Configuration Manager) so that the app compiles and runs 32-bit. There is no 64-bit version of Jet OLEDB.

    Also, you may want to post your complete connection string again (including the Excel filename) so that we can make certain the syntax is correct. Below is an example that I have which works:

        ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                  "Data Source=C:\Test Files\Book20.xls;" & _
                  "Extended Properties=""Excel 8.0;IMEX=1;HDR=No"""
    
    

    Paul ~~~~ Microsoft MVP (Visual Basic)
    Thursday, May 12, 2011 4:05 PM
  • Hi MyLoginID,

    I made a test on my side. It works. Please check it.

    Dim filepath As String = "C:\Users\Administrator\Desktop\"
    Dim filename As String = "LarcolaisExcel.xls"
    
    Using connection As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & "data source='" & filename & " '; " & "Extended Properties=Excel 8.0;")

    If you have any question, welcome to post back.

    Hope this helps.

    Best Regards,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    Friday, May 13, 2011 1:14 PM

All replies

  • Hi My LoginID,

    Thank you for posting.

    From your description, it looks that you question is related with the concatenation of connection.

    I suggest you can check this thread which was similar like yours.

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/62ee4978-ca29-48d3-9367-6dd4ab639d2d/

    Hope this helps.

    Best Regards,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 12, 2011 10:54 AM
  • There should be a space between "Excel" and "8.0". If you have incorrect syntax in your SQL statement, such as the mentioned typo, this can generate the "installable ISAM" error.


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Thursday, May 12, 2011 1:12 PM
  • Hello Paul,

     I tried giving space in between. But that didn't work.

    Thanks

     

     

    Thursday, May 12, 2011 2:52 PM
  • Are you running 64-bit Windows? If so, change the Platform option to x86 (Build...Configuration Manager) so that the app compiles and runs 32-bit. There is no 64-bit version of Jet OLEDB.

    Also, you may want to post your complete connection string again (including the Excel filename) so that we can make certain the syntax is correct. Below is an example that I have which works:

        ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                  "Data Source=C:\Test Files\Book20.xls;" & _
                  "Extended Properties=""Excel 8.0;IMEX=1;HDR=No"""
    
    

    Paul ~~~~ Microsoft MVP (Visual Basic)
    Thursday, May 12, 2011 4:05 PM
  • Hi MyLoginID,

    I made a test on my side. It works. Please check it.

    Dim filepath As String = "C:\Users\Administrator\Desktop\"
    Dim filename As String = "LarcolaisExcel.xls"
    
    Using connection As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & "data source='" & filename & " '; " & "Extended Properties=Excel 8.0;")

    If you have any question, welcome to post back.

    Hope this helps.

    Best Regards,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    Friday, May 13, 2011 1:14 PM