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 4273434
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:42:45+00:00 2026-05-21T07:42:45+00:00

I have a weird issue reading a .csv file using c#. Here are the

  • 0

I have a weird issue reading a .csv file using c#. Here are the file contents:

**ColumnName,                   Column Value**
Bestemming,                     aaa.asp
BuEn_SubSystem,                 B
BusinessListActive,             FALSE
cancreatelogin,                 0
CDTAccess,                      Y
CDTAssessmentNo,                4172
CDTAssessRO,                    N
CDTCntComp,                     0
CDTCntOnf,                      0
***CDTExpiry,                   1***

I am using the following code to read the file:

using System;
using System.Data;
using System.IO; //not used by default
using System.Data.OleDb; //not used by default


class CSVParser
    {
        public static DataTable ParseCSV(string path)
        {
            if (!File.Exists(path))
                return null;

            string full = Path.GetFullPath(path);
            string file = Path.GetFileName(full);
            string dir = Path.GetDirectoryName(full);


            //create the "database" connection string 
            string connString = "Provider=Microsoft.Jet.OLEDB.4.0;"
               + "Data Source=\"" + dir + "\\\";"
               + "Extended Properties=\"text;HDR=Yes;FMT=Delimited\"";

            //create the database query

            string query = "SELECT * FROM " + "[" + file + "]";

            //create a DataTable to hold the query results
            DataTable dTable = new DataTable();


            //create an OleDbDataAdapter to execute the query
            OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);

            try
            {
                //fill the DataTable
                dAdapter.Fill(dTable);                  

            }
            catch (InvalidOperationException /*e*/)
            { }

            dAdapter.Dispose();

            return dTable;
        }
    }

for some reason the CDTExpiry field is giving an issue. All I have to do is change the numeric to non-numeric for that field only and it works fine!! e.g CDTExpiry,1 to CDTExpiry,a.

Anyone know why this would be happening, as I am using this code for a bulk load of data from the csv file, and I don’t want to always check the file first for this line of Code.

tx

  • 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-21T07:42:46+00:00Added an answer on May 21, 2026 at 7:42 am

    I believe there is an Extended Property in the Microsoft.Jet library that allows for something like this….I remember having a similar issue several years ago and I think I fixed it that way. Do some Googling about the extended properties and see if you can find one that will help your field accept a numeric

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

Sidebar

Related Questions

I am having some weird issue here. I have a database table which has
I have a weird issue that only seems to be affecting IE 7. The
We have a semi-weird issue for our site. Consistently, from 1 anonymous* user the
I have seen some very weird for loops when reading other people's code. I
I'm reading email from a maildir and some emails have weird sets of characters
I have many processes reading a file stored on a network share. Originally I
I have Magento 1.3.2 and I have weird issue: When I am in list.phtml
I have a weird issue when committing changes in NHibernate. It doesn't throw an
I have a very weird issue. I have a UserControl that has some controls
Having a weird issue. I'm new to Macs and have a windows VM that

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.