locked
Data from Excel - connection string RRS feed

  • Question

  • User-341952562 posted

    I am trying to import some data from an Excel spreadsheet. With the following code, I am getting a "Could not find an installable ISAM" server error and it highlights the last line of the snippet given below.

    I think this message often means that there is an error in the connection string, but I can't see what the problem is and trial and error hasn't worked yet.

    <code>

    '
    ' Create the connection string for the EXCEL file containing the filename and Provider settings.
    '
    Dim root As String
    root = HttpContext.Current.Server.MapPath("BoxStore")
    Dim filepath As String = root & "\" & "Box_zero.xls"
    Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=filepath;ExtendedProperties=""Excel 8.0;HDR=No;IMEX=0"";"
    '
    ' Create a new connection object and open it for processing.
    '
    Dim objConn As OleDbConnection = New OleDbConnection(connectionString)
    objConn.Open()
    </code>

    Can anyone spot the problem, please ?


    Saturday, December 18, 2010 5:21 AM

Answers

  • User551462331 posted

    if you have excel 2003... then this connectionstring should work....

    i tried to find any error in u r connecctionstring from here

    http://www.connectionstrings.com/excel

    only diffrence i can locate is...

    extended properties is writen as extendedProperties (no space)

    i m not sure if that can cause any issue... u can try..

    also.... source=filepath

    if filepath is varialbe which holds actual file path... then it should have been

    " ...... source = " & filePath & "; extednde properties = ""...blah blah

    hope this helps...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 18, 2010 5:53 AM

All replies