Solved

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

Posted on 2006-10-27
4
1,507 Views
Last Modified: 2012-06-21
   
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?

0
Comment
Question by:piershughes
  • 3
4 Comments
 

Author Comment

by:piershughes
ID: 17820332
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....
0
 
LVL 29

Accepted Solution

by:
leonstryker earned 300 total points
ID: 17821915
0
 

Author Comment

by:piershughes
ID: 17822287
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"
0
 

Author Comment

by:piershughes
ID: 17822313
Leon
I'll give you the points since yours seems to work a little faster than mine... not sure why!
Thanks for the assist
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question