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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:53:55+00:00 2026-05-23T18:53:55+00:00

Here is my datatable: DataTable CSVFile = new DataTable(); CSVFile.Columns.Add(Occurrence_Date, typeof(DateTime)); CSVFile.Columns.Add(Preanalytical_Before_Testing, typeof(string)); CSVFile.Columns.Add(Cup_Type,

  • 0

Here is my datatable:

DataTable CSVFile = new DataTable();
CSVFile.Columns.Add("Occurrence_Date", typeof(DateTime));
CSVFile.Columns.Add("Preanalytical_Before_Testing", typeof(string));
CSVFile.Columns.Add("Cup_Type", typeof(string));
CSVFile.Columns.Add("Analytical_Testing_Phase", typeof(string));
CSVFile.Columns.Add("Area", typeof(string));
CSVFile.Columns.Add("Postanalytical_After_Testing", typeof(string));
CSVFile.Columns.Add("Other", typeof(string));
CSVFile.Columns.Add("Practice_Code", typeof(string));
CSVFile.Columns.Add("Comments", typeof(string));

I am trying to add a new row to it:

DataRow newRow = CSVFile.NewRow();
newRow["Occurrence_Date"] =  Convert.ToDateTime(splitcsvlines[GetColumnsNames.Occurrence_Date]);
newRow["Preanalytical_Before_Testing"] = splitcsvlines[GetColumnsNames.Preanalytical_Before_Testing];
newRow["Cup_Type"] = splitcsvlines[GetColumnsNames.Cup_Type];
newRow["Analytical_Testing_Phase"] = splitcsvlines[GetColumnsNames.Analytical_Testing_Phase];
newRow["Area"] = splitcsvlines[GetColumnsNames.Area];
newRow["Postanalytical_After_Testing"] = splitcsvlines[GetColumnsNames.Postanalytical_After_Testing];
newRow["Other"] = splitcsvlines[GetColumnsNames.Other];
newRow["Practice_Code"] = splitcsvlines[GetColumnsNames.Practice_Code];
newRow["Comments"] = splitcsvlines[GetColumnsNames.Comments];
CSVFile.Rows.Add(newRow);

However I am getting an error

The type initializer for ‘BulkUploadToLOMDatabase.GetColumnsNames’ threw an exception.`

I have tried to just do newRow["Cup_Type"] = "something" or newRow[2] = "something" and still getting the same error

Here is what the class looks like:

class GetColumnsNames
{

  public static int Occurrence_Date = Convert.ToInt16(ConfigurationSettings.AppSettings["Occurrence_Date"].ToString());
  public static int Preanalytical_Before_Testing = Convert.ToInt16(ConfigurationSettings.AppSettings["1_0_Preanalytical_Before_Testing"].ToString());
  public static int Cup_Type = Convert.ToInt16(ConfigurationSettings.AppSettings["Cup_Type"].ToString());
  public static int Analytical_Testing_Phase = Convert.ToInt16(ConfigurationSettings.AppSettings["Analytical_Testing_Phase"].ToString());
  public static int Area = Convert.ToInt16(ConfigurationSettings.AppSettings["Area"].ToString());
  public static int Postanalytical_After_Testing = Convert.ToInt16(ConfigurationSettings.AppSettings["Postanalytical_After_Testing"].ToString());
  public static int Other = Convert.ToInt16(ConfigurationSettings.AppSettings["Other"].ToString());
  public static int Practice_Code = Convert.ToInt16(ConfigurationSettings.AppSettings["Practice_Code"].ToString());
  public static int Comments = Convert.ToInt16(ConfigurationSettings.AppSettings["Comments"].ToString());
}

What am i doing wrong? What is wrong with my class?

  • 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-23T18:53:56+00:00Added an answer on May 23, 2026 at 6:53 pm

    The type initializer for BulkUploadToLOMDatabase.GetColumnsNames' threw an exception.

    This means that the CLR tried create your type but it failed. Since you have a bunch of static variables that rely on a call that could fail wth KeyNotFound FormatExecption NullException you should convert this class to a singleton instead.

    This way you can properly catch any problems with ConfigurationSettings.AppSettings

    As an aside you might want to consider using system.configuration.configurationmanager instead. That is unless you’re in 1.1. ConfigurationSettings.AppSettings went obsolete in 2.0

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

Sidebar

Related Questions

I am trying to convert all DateTime values in a DataTable to strings. Here
Here's my code: [Serializable()] public class Project { private List<string> _Kinds = new List<string>();
IDE : VS 2008, Platform : .NET 3.5, Hi, Here is my DataTable columns
I am trying to add a datatable to a database. Here's what I've been
I've a simple code, here I add a row to my a datatable which
I have a rich:Datatable with dynamic columns... Till here its ok... I get all
c#/oop noob here. I am creating a datatable from the schema of a sql
I need to get the minimum DateTime value of a column in a DataTable.
Here is a minimal rich:dataTable example with an a4j:commandLink inside. When clicked, it sends
i have an datatable with column unit. here column name is unit unit abc

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.