Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

914 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

18 Experts available now in Live!

Get 1:1 Help Now