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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:15:45+00:00 2026-06-09T06:15:45+00:00

I have an excel sheet with 18 columns. In that 5 columns have same

  • 0

I have an excel sheet with 18 columns. In that 5 columns have same column name CALL_REASON. But when i load that excel sheet into a dataset using Microsoft.ACE.OLEDB.12.0. The column names in dataset are changed for the columns which had same name. it is getting loaded as CALL_REASON,CALL_REASON1,CALL_REASON2,CALL_REASON3,CALL_REASON4. They are present in excelsheet as CALL_REASON,CALL_REASON,CALL_REASON,CALL_REASON,CALL_REASON

String properties = "Excel 8.0; HDR=YES; IMEX=1;";//properties set for connection to excel
string sSourceConstr = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\uploads\" + fileName + ";Extended Properties=\"" + properties + "\"";

sSourceConnection = new OleDbConnection(sSourceConstr);//creating the OLEDB connection
try
{
    //select statement to select data from the first excel sheet
    string sql = string.Format("Select * FROM [{0}]", "Sheet1$");

    //commands to fill the dataset with excel data
    OleDbDataAdapter excelAdapter = new OleDbDataAdapter();
    OleDbCommand command = new OleDbCommand(sql, sSourceConnection);
    sSourceConnection.Open();
    excelAdapter.SelectCommand = command;
    excelAdapter.Fill(surveyItemDetails, "ExcelDataTable");
}
  • 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-09T06:15:47+00:00Added an answer on June 9, 2026 at 6:15 am

    You cannot have fields with the same name in a DataTable. In fact, you cannot even have CALL_REASON and CALL_reason, see, for example, the Exceptions section in the documentation of DataColumnCollection.Add:

    DuplicateNameException

    The collection already has a column with the specified name. (The comparison is not case-sensitive.)

    The requirement that column names must be unique makes perfect sense. What should be returned by DataRow.Field<String>("CALL_REASON"), if you were allowed to have multiple columns with that name?

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

Sidebar

Related Questions

I have an excel sheet that I want to load into a datatable withe
I have an Excel sheet that I am using to populate data in a
I have a Excel sheet with two columns and I need to create new
I have an Excel sheet with two column, one is a number , and
I have an excel sheet that has several headers. One of the header is
I have created Excel Sheet using Java program. It works fine. My problem is,
I have an excel sheet that is organized as follows: COL1 COL2 1 30
I have the same problem. But the differences is that my empty rows are
I have a dataset that consists of 6 tables. When I place them into
I have an EXCEL sheet.it has various form-fields that are named as smrBgm133GallonsGross/ smrBgm167GallonsGross

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.