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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:40:44+00:00 2026-05-22T20:40:44+00:00

I am importing values like 0000,0002,0023,0034 from a text file. However, the table shows

  • 0

I am importing values like 0000,0002,0023,0034 from a text file. However, the table shows them as 0, 2, 23, 34. Does anyone know why it is removing the leading zeros?

Here is my code:

private DataTable ImportTabFile()
{
    string dataSourcePath = @"C:\Documents and Settings\agordon\Desktop";
    string dataFileName = "ACTIVITYEX.txt";
    string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dataSourcePath + @";Extended Properties=""text;HDR=No;FMT=Delimited""";
    OleDbConnection conn = new OleDbConnection(connString);
    OleDbCommand cmd = conn.CreateCommand();
    cmd.CommandText = String.Format("SELECT * FROM [{0}]", dataFileName);
    DataSet ds = new DataSet();
    OleDbDataAdapter da = new OleDbDataAdapter(cmd);

    da.Fill(ds);

    return ds.Tables[0];
}

How can I keep the leading zeroes during the import?

here is what my schema file looks like:

[ACTIVITYEX.txt]
Format=TabDelimited
ColNameHeader=False
Col13=ErrorCode Text
  • 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-22T20:40:45+00:00Added an answer on May 22, 2026 at 8:40 pm

    JET will infer types based on the first row. It is probably inferring your fields are INT because 0000 can be converted to a number. As mentioned above, leading zeroes are useless.

    You can use schema.ini to explicitly define the column types. As noted in the comments above, you need to specify each column as per the documentation:

    You must specify each column by number and designate the column name, data type, and width for fixed-length files.

    Alternatively this article has some information on controlling how the types are inferred.

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

Sidebar

Related Questions

When importing numbers from a csv file, I need to convert them to floats
I'm importing some data from a CSV file, and numbers that are larger than
I'm importing data from a SQL Cube and have several row labels I'd like
So the file I am importing into a ListBox looks like this (each newline
After importing content from a legacy website using the Feeds module, I'm left with
I am importing the CreateICeeFileGen() function from the unmanaged DLL mscorpe.dll in a C#
We are importing from CSV to SQL. To do so, we are reading the
I have a spreadsheet with the following values: CUST_ID, NAME, PHONE, EMAIL 0000, John
I have a table that looks like something like this: timestamp value person ===============================================
I would like to distinguish date at midnight (i.e. '12/05/2010 00:00:00') from date without

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.