?
Solved

problem with excel driver?

Posted on 2002-07-15
10
Medium Priority
?
196 Views
Last Modified: 2010-05-02
I have a problem with excel driver
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.xls;Extended Properties="Excel 8.0;HDR=NO;"

Some of the fields does actually have value but the recordset.Fields(xxx).value record as null,

Is there any wrong with provider above? anyone have similar problem/solution for it
0
Comment
Question by:AStronus
[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
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 1

Expert Comment

by:ophirg
ID: 7156467
Hi.

Try using this connection string:

ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=DBQ=C:\myFile.xls;DefaultDir=C:\;Driver={Microsoft Excel Driver (*.xls)};DriverId=790;FIL=excel
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7156516
This happens sometimes when the ODBC or OLEDB try to determine the data type upon the first rows, guessing by the values that it finds. If the first rows have numerical values, the data type is fixed to numerical, even if some rows later a alphanumeric value is present. Those values then are returned as NULL, as the conversion is not successful.
The only workaround this I used is to get the data using Automation...

CHeers
0
 

Author Comment

by:AStronus
ID: 7157345
ophirg, it's seem like working for me for ur connectionstring, I wonder does it's suppose all operation system? I'm using NT system so i'm not so sure.

Angell, can you tell me more about automation? I got no idea about it
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:AStronus
ID: 7157367
ophirg, I only able to obtain the first row only which is the name, recordset.fields(i).name which i is columns number

I cannot get the value of it
0
 

Author Comment

by:AStronus
ID: 7157581
ophirg, I got the value, but the provider changing the character in my excel. Eg [ -> ( , ] -> ), .(dot) -> #
0
 
LVL 1

Accepted Solution

by:
ophirg earned 800 total points
ID: 7158726
Hi.

   It seems like we are living in two different time zones, therfore my answer is a bit delayed.

   One thing I should have mentioned, but forgot is the syntax of your query (SQL).

Here is the full answer to your problem:
Dim strConnectionString As String
    Dim cn As Connection
    Dim rs As Recordset
   
    Set cn = New Connection
    Set rs = New Recordset
   
    strConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=DBQ=C:\Ophir.xls;DefaultDir=C:\;Driver={Microsoft Excel Driver (*.xls)};DriverId=790;FIL=excel"
   
    With cn
        .ConnectionString = ConnectionString
        .Open
    End With
   
    With rs
        Set .ActiveConnection = cn
   
       .Open "SELECT * FROM [mySheet$]"
       
       Debug.Print rs(0).Value          
       rs.MoveNext
       Debug.Print rs(0).Value          
    End With

......


Hope this helps,
Ophir.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7158767
automation:

dim objExcel as object 'or Excel.Application
set objExcel = Createobject("Excel.Application")

dim objWorkbook as object ' or Excel.Workbook
set objWorkbook = objExcel.Workbooks.Open("fullpath\test.xls")

dim objSheet as object 'or Excel.Sheet
set objSheet = objWorkbook.Sheets(1) 'or by name Sheets("Sheet1")

'now loop through the rows, say column 1 ("A") must be filled to contain a row, as soon as this cell is empty, stop the loop.
'Also, the first row contains the headers, so start at 2nd row:
dim lngRow as long
lngRow = 2
while objSheet.Cells(lngRow,1).Value <> empty
  'now, instead of having rs(n).value, you read objSheet.Cells(lngRow, n).Value
 

  lngRow = lngRow+1
Wend  

'cleanup
set objSheet = nothing
objWorkbook.Close save:=false
set objWorkbook = nothing
objExcel.Quit
set objExcel = nothing


CHeers
0
 

Author Comment

by:AStronus
ID: 7160688
ophirg, I got the value, but the provider changing the character in my excel. Eg [ -> ( , ] -> ), .(dot) -> #
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8012542
Hi AStronus,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept ophirg's comment(s) as an answer.

AStronus, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 8096036
Comment from expert accepted as answer

Computer101
E-E Admin
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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.
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…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

770 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