Link to home
Start Free TrialLog in
Avatar of piershughes
piershughes

asked on

Reading Excel file as datasource in VB -- long fields issue

   
I am using the following code to open an excel doc and doing a join between 2 worksheets to get a single recordset.

    ExcelCN.Provider = "Microsoft.Jet.OLEDB.4.0"
    ExcelCN.ConnectionString = "Data Source=" & "myfile.xls" & ";Extended Properties=Excel 8.0;"
    ExcelCN.Open


    sSQL = "SELECT * FROM [table1$] T1 LEFT JOIN [table2$] T2 ON T1.Code=T2.code"

    Set ExcelRS = New ADODB.Recordset
    ExcelRS.Open sSQL, ExcelCN

This creates a recordset with all the fields that I require except that when I look at fields where the content is over a certain (don't exactly know how many char) size it contains a Null value.
I saw a solution suggested in a previous question where increasing the scan to 16 and defining that there is a header would help, however when I tried changing the connection params:
ExcelCN.ConnectionString = "Data Source=" & "myfile.xls" & ";Extended Properties=Excel 8.0;HDR=Yes;MAXSCANROWS=16"

I get an error saying "Could not find installable ISAM"

Any ideas?

Avatar of piershughes
piershughes

ASKER

Just tried changing the Excel version to "Excel 10.0" leaving off the "HDR=Yes;MAXSCANROWS=16" and get the same error ...
"Could not find installable ISAM"

This seems odd since I'm running Excel 2002 (XP) which should be Excel 10.0 I believe....
ASKER CERTIFIED SOLUTION
Avatar of leonstryker
leonstryker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I found this and it seems to work..

        ExcelCN.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=Excel Files;Mode=Read;Initial Catalog=myfile.xls"
Leon
I'll give you the points since yours seems to work a little faster than mine... not sure why!
Thanks for the assist