Results 1 to 9 of 9

Thread: [2005] Very strange Excel problem...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    Between Try & Catch
    Posts
    249

    [2005] Very strange Excel problem...

    Ok,

    I have a web application that reads in data from an Excel spreadsheet. Seems to work fine, but I'm getting some strange behavior from one of the Excel columns.

    Here is the scenario:
    A user uploads a spreadsheet, the app reads in the data from all the columns. On this particular column, called Relo, if there is at least one value for this column within the first few rows, the rest of the rows with a value for this column will be read as well. However, if there is no value in the column after the first few rows, I always get an empty string for the value in later rows, even if there is a legitimate value in the column.

    Has anyone ever encountered this? I cannot for the life of me figure out what could be potentially causing this behavior.

    Edit: Don't know if it matters any, but we're using Office 2003.
    Last edited by Blakk_Majik; Nov 6th, 2008 at 02:26 PM.
    If my post helped you, please rate it!

    Languages: VB/ASP.NET 2005, C# 2008,VB6
    Databases: Oracle (knowledge not currently in use), DB2

    FROM Customers
    WHERE We_Know_What_We_Want <> DB.Null
    SELECT *
    0 rows returned

  2. #2
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: [2005] Very strange Excel problem...

    what connectionstring are you using?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    Between Try & Catch
    Posts
    249

    Re: [2005] Very strange Excel problem...

    I'm not sure what you mean.
    If my post helped you, please rate it!

    Languages: VB/ASP.NET 2005, C# 2008,VB6
    Databases: Oracle (knowledge not currently in use), DB2

    FROM Customers
    WHERE We_Know_What_We_Want <> DB.Null
    SELECT *
    0 rows returned

  4. #4
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: [2005] Very strange Excel problem...

    how are you connecting to excel to read data from it? What code do you have to do this?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    Between Try & Catch
    Posts
    249

    Re: [2005] Very strange Excel problem...

    Is this what you are referring to?

    Dim objExcel As New OleDbCommand("SELECT * FROM [User_Upload$]", objConn)
    Dim Excelreader As OleDbDataReader = objExcel.ExecuteReader()
    If my post helped you, please rate it!

    Languages: VB/ASP.NET 2005, C# 2008,VB6
    Databases: Oracle (knowledge not currently in use), DB2

    FROM Customers
    WHERE We_Know_What_We_Want <> DB.Null
    SELECT *
    0 rows returned

  6. #6
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: [2005] Very strange Excel problem...

    not quite... what is objConn. what value is that?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    Between Try & Catch
    Posts
    249

    Re: [2005] Very strange Excel problem...

    Well, we have discovered a solution.

    At the end of the connection string, I put IMEX=1. I'm not completely satisfied with this though, since it declares everything on the spreadsheet as text (from what I've been told). Luckily all the app cares about is the values, not format, so we're in the clear this time.

    Thanks for your help techno. Once I found the solution, it was then I finally figured out why you wanted me to show the connection string.
    If my post helped you, please rate it!

    Languages: VB/ASP.NET 2005, C# 2008,VB6
    Databases: Oracle (knowledge not currently in use), DB2

    FROM Customers
    WHERE We_Know_What_We_Want <> DB.Null
    SELECT *
    0 rows returned

  8. #8
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: [2005] Very strange Excel problem...

    This is what i was trying to aim at... hehe

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  9. #9
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: [2005] Very strange Excel problem...

    From what I know the problem could be caused because excell determines the dataType of each column from the first few entries in each column. This can be problematic as you discoverd.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width