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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:58:36+00:00 2026-06-07T21:58:36+00:00

Possible Duplicate: How in .Net do I Import Values from a CSV in the

  • 0

Possible Duplicate:
How in .Net do I Import Values from a CSV in the format I want using OleDB?

I have a csv file which I read using OleDbCommand.

The CSV contains columns that are numbers that are left padded with 0.
When I read the columns, I get the results without any leading 0 characters: It is now a number.

These values in the CSV:

UserNumber    LocationNumber
00001234      00023456
00891234      00000456

becomes

UserNumber    LocationNumber
1234      23456
891234      456

In the resulting datatable filled by my OleDbDataAdapter.

Is there any way to prevent this?

PS, Padding is not an issue, but due to the nature of the work being done, not really a good solution as the CSV files have no set format.

  • 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-06-07T21:58:38+00:00Added an answer on June 7, 2026 at 9:58 pm

    It seems to me like you won’t mind though just reading the whole file as strings. You can just build your Schema.ini file like that pretty easily.

    Using your original connection:

    DataTable GetSchemaTable() 
    {
        try
        {
            OleDbDataAdapter da; // init adapater with your own connection
            DataSet ds = new DataSet();
            System.Data.DataTable[] dtTables = da.FillSchema(ds, SchemaType.Source);
            return dtTables[0];
        }
        catch (System.Exception se)
        {
            throw new System.Exception("Problem retrieving Schema: " + se.Message);
        }
    }
    
    void CreateSchemaIni(string csvDirectory, string csvFileName) 
    {       
        DataTable dt = GetSchemaTable();
        FileStream fsOutput = new FileStream(csvDirectory + "\\schema.ini", FileMode.Create, FileAccess.Write);
        StreamWriter srOutput = new StreamWriter(fsOutput);
        string s1, s2, s3;
        s1 = "[" + csvFileName + "]";
        s2 = "ColNameHeader=False";
        s3 = "Format=CSVDelimited";
        srOutput.WriteLine(s1 + '\n' + s2 + '\n' + s3 + '\n');
        StringBuilder strB = new StringBuilder();
        for (int i = 1; i <= dt.Columns.Count; i++)
        {
            strB.Append("Col" + i.ToString());
            strB.Append("=F" + i.ToString());
            strB.Append(" Text\n");
            srOutput.WriteLine(strB.ToString());
            strB = new StringBuilder();
        }
        srOutput.Close();
        fsOutput.Close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: .Net Zip Up files I want to zip a .csv file using
Possible Duplicate: CSV File Imports in .Net In .net, is there a standard library
Possible Duplicate: SendInput and 64bits I'm using SendInput from .NET code (PInvoke). code used
Possible Duplicate: .NET Convert from string of Hex values into Unicode characters (Support different
Possible Duplicate: ASP.NET MVC3 how to excute action method of controller using timer with
Possible Duplicate: ASP.Net:Best way to run scheduled tasks I have to make a scheduled
Possible Duplicate: Protect .NET code from reverse engineering? we just develop a application with
Possible Duplicate: Modifying .NET Dictionary while Enumerating through it I have a dictionary object
Possible Duplicate: Using ASP.NET Controls without databinding My previous question yielded few results so
Possible Duplicate: .Net Process.Start default directory? I have a C# application, mono to be

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.