Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6132671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:07:51+00:00 2026-05-23T17:07:51+00:00

i am trying to read in some data from an excel: If (FileUpload1.PostedFile.ContentType =

  • 0

i am trying to read in some data from an excel:

If (FileUpload1.PostedFile.ContentType = "application/vnd.ms-excel") Then
                Dim filename As String = Path.GetFileName(FileUpload1.FileName)
                'Session("userid") & "-" & Date.Now()
                filepath = "\excel\" & Session("userid") & "_" & Now.Date().ToString("Mdy") & "_" & filename
                FileUpload1.SaveAs(Server.MapPath("~/") & filepath)
                ReadExcel(filepath)

            Else
                StatusLabel.Text = "Only Excel file types are accepted"
            End If

everything seems to be fine, except when one of the columns sometimes reads in as NULL. seems like that happens if it’s of a different type.
i can’t figure out what it is. someone help me please….

Sub ReadExcel(ByVal filepath As String)
    Dim MyConnection As System.Data.OleDb.OleDbConnection
    Dim DtSet As System.Data.DataSet
    Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
    MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & Server.MapPath("~/") & filepath & "';Extended Properties=Excel 8.0;")

    DtSet = New System.Data.DataSet
    Try
        MyCommand.Fill(DtSet)
        'gwResults.DataSource = DtSet.Tables(0)
        LoopSources(DtSet)
        'gwResults.DataBind()
        MyConnection.Close()
    Catch ex As Exception
        StatusLabel.Text = "Import Excel status: The file could not be loaded. The following error occured: <br>" + ex.Message
    End Try

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:07:52+00:00Added an answer on May 23, 2026 at 5:07 pm

    You need to include Extended Properties="Excel 8.0;IMEX=1;" in your connection string. Excel tries to determine the data type of your columns by reading the first few rows. Once it thinks it knows the data type, anything that doesn’t conform to that is coerced to NULL. Very annoying. IMEX=1 tells it to read your data as intermixed and should resolve your problem. If you have a header row, you should also consider including HDR=YES. See this link: http://www.connectionstrings.com/excel for more info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read in some sample data from an XML file in a
I'm trying to measure how long it takes read then encrypt some data (independently).
I was trying to read data from some huge file and write them back,
I am trying to read some data from html forms and insert it into
I'm trying to read some JSON data from the Tumblr API. I'm using the
I am building application that required some data from iPhone's Call log(read only). The
Im trying to read some data from a binary file into a buffer allocated
Hello I'm trying to read some data from the serial port and record it
I am trying to read some data from a xml file, numbers are saved
I'm getting something pretty strange going on when trying to read some data using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.