Solved

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

Posted on 2006-10-27
4
1,497 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now