DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Feb 2009
    Posts
    3

    Problem on reading Excel file by ADO

    Hi guys,

    I have a function in VB to connect information from a excel file (xls) by ado.

    I'm having problems on a column mix with number and english characters. I found that when the field only contain number, the system will fail to read the value and return NULL.
    Note: No special cell formatting have been apply to the excel file, all cells are using default General type.

    Example:
    The A2 cell will return NULL, wile A1 and A3 are fine

    A B C D
    policy119 CompanyA FileA.txt Comment1
    2678 CompanyB FileB.txt Comment2
    188policy CompanyC FileC.txt Comment3


    rstData.Source = "Select * From [" & tableName & "]"
    rstData.Open, objExcelConn

    Do While Not rstData.EOF
    If IsNull(.Fields("A").Value) = False Then
    PrintReport (.Fields("A").Value,.Fields("B").Value,.Fields("C").Value,.Fields("D").Value)
    else
    CounterErr = CounterErr + 1
    End If
    rstData.MoveNext
    Loop


    Can somebody help

    Thanks a lot.



    NOTE:
    1) I found that if I manually add an apostrophe (" ' " char) before the number will solve the problem, any idea why it act like this?
    2) And I have a few thousand of records like this, any suggestion on let the program identify the field only contain number and need to add the " ' " before getting the value in VB.

    A B C D
    policy119 CompanyA FileA.txt Comment1
    '2678 CompanyB FileB.txt Comment2
    188policy CompanyC FileC.txt Comment3
    Last edited by mkmkmk2; 02-12-2009 at 10:59 PM.

Similar Threads

  1. Replies: 0
    Last Post: 07-08-2002, 11:37 AM
  2. Ado using Data Link File Question
    By KENHOW in forum VB Classic
    Replies: 0
    Last Post: 07-13-2001, 04:02 PM
  3. NullPointerException when reading text file
    By Andrew McLellan in forum Java
    Replies: 3
    Last Post: 05-09-2001, 05:34 PM
  4. Replies: 0
    Last Post: 03-05-2001, 05:24 AM
  5. ADO Data Control Problem
    By Kamal in forum VB Classic
    Replies: 0
    Last Post: 06-19-2000, 07:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links