?
Solved

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

Posted on 2006-10-27
4
Medium Priority
?
1,513 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 900 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 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