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

  • Home
  • SEARCH
  • 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 3675316
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:57:40+00:00 2026-05-19T02:57:40+00:00

We’re converting a Classic ASP site to an ASP.NET site. One function was to

  • 0

We’re converting a Classic ASP site to an ASP.NET site. One function was to upload a ‘template’ of data in CSV format for importing into the database. There were several different record types in there (the first field always indentifies the type of data).

The task was to get the CSV into a DataTable so it could be validated (new project is to have MUCH better validation rules)

The code seemed pretty straightforward – watered down (taking out comments, Try/Catch, etc) it is as follows:

    Dim da As New System.Data.OleDb.OleDbDataAdapter
    Dim cn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDirectory & ";" & "Extended Properties=""Text;HDR=No;FMT=Delimited;""")
    Dim cd As New System.Data.OleDb.OleDbCommand("SELECT * FROM " & strCSVFilename, cn)
    cn.Open()
    da.SelectCommand = cd
    da.Fill(dtData)

The DataTable (dtData) is populated, but only starting with the second line of the CSV file DESPITE the fact that “HDR=No” is in the connection string.

What am I missing here?

  • 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-19T02:57:41+00:00Added an answer on May 19, 2026 at 2:57 am

    Is there maybe something at the begining of the file that’s causing the first row to be skipped? Maybe a non-printable character? The NPC could come from the file not being saved in an expected encoding. When I created a CSV file I received the results that you expected. Here’s the code that I used to test:

        Private Sub Test()
        Dim TempDir = My.Computer.FileSystem.SpecialDirectories.Temp
        Dim TempFile = "Test.csv"
    
        '//Create our test file with a header row and three data rows
        Using FS As New System.IO.FileStream(System.IO.Path.Combine(TempDir, TempFile), IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.Read)
            Using SW As New System.IO.StreamWriter(FS, System.Text.Encoding.ASCII)
                SW.WriteLine("Col1,Col2")
                SW.WriteLine("R1", "R1")
                SW.WriteLine("R2", "R2")
                SW.WriteLine("R3", "R3")
            End Using
        End Using
    
        '//Read the data into a table specifying that the first row should be treated as a header
        Using dtData As New DataTable()
            Using da As New System.Data.OleDb.OleDbDataAdapter
                Using cn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & TempDir & ";" & "Extended Properties=""Text;HDR=Yes;FMT=Delimited;""")
                    Using cd As New System.Data.OleDb.OleDbCommand("SELECT * FROM " & TempFile, cn)
                        cn.Open()
                        da.SelectCommand = cd
                        da.Fill(dtData)
                        Trace.WriteLine("With header,    expected 3, found " & dtData.Rows.Count)
                    End Using
                End Using
            End Using
        End Using
    
        '//Read the data into a table again, this time specifying that the there isn't a header row
        Using dtData As New DataTable()
            Using da As New System.Data.OleDb.OleDbDataAdapter
                Using cn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & TempDir & ";" & "Extended Properties=""Text;HDR=No;FMT=Delimited;""")
                    Using cd As New System.Data.OleDb.OleDbCommand("SELECT * FROM " & TempFile, cn)
                        cn.Open()
                        da.SelectCommand = cd
                        da.Fill(dtData)
                        Trace.WriteLine("Without header, expected 4, found " & dtData.Rows.Count)
                    End Using
                End Using
            End Using
        End Using
    
        '//Delete our temporary file
        System.IO.File.Delete(System.IO.Path.Combine(TempDir, TempFile))
    End Sub
    

    If you change the initial encoding to Unicode you’ll get 8 and 9 rows in the results instead which is maybe what you’re seeing. If it turns out to be an encoding problem you can add CharacterSet=Unicode to your extended properties.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
this is what i have right now Drawing an RSS feed into the php,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.