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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:14:37+00:00 2026-05-27T06:14:37+00:00

I am getting some data in unstructured form. So i want it to be

  • 0

I am getting some data in unstructured form. So i want it to be in structured form. So i take datatable in this i have added two columns, i.e. “field” and “value”. Now i added first row in data along with the data in these two columns. But the prob is its replacing the old data every time i come again to save the data in this datatable. My code is:

     DataTable dt = new DataTable();
            dt.Columns.Add("Field", typeof(string));
            dt.Columns.Add("Value", typeof(string));
            dt.Rows.Add(val.Substring(0, val.IndexOf(":") + 1), val.Substring(val.IndexOf(":") + 1, val.Length - val.IndexOf(":") - 1))
  • 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-27T06:14:38+00:00Added an answer on May 27, 2026 at 6:14 am

    Using DataTable, you have to create a new row before adding it:

    DataTable dt = new DataTable();
    dt.Columns.Add("Field", typeof(string));
    dt.Columns.Add("Value", typeof(string));
    
    var row = dt.NewRow();
    dt["Field"] = "FieldName";
    dt["Value"] = "Value";
    dt.Rows.Add(row);
    

    NewRow() documentation :

    You must use the NewRow method to create new DataRow objects with the
    same schema as the DataTable. After creating a DataRow, you can add it
    to the DataRowCollection, through the DataTable object’s Rows
    property. When you use NewRow to create new rows, the rows must be
    added to or deleted from the data table before you call Clear.

    But if you are only handling a key/value pair, why don’t you use a Dictionary<string, string> ?

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

Sidebar

Related Questions

Getting unique rows/values in SQL. I have same some data like this valueA ValueB
Currently i am having some problems with getting some data out of a DataTable
I have a data table which already has some values, plus it is getting
On my activity, im getting some big data from web, and while getting this
I am having trouble getting some data from a JSON object which I have
I am trying to have a ProgressDialog appear when I am getting some data,
I'm passing some data between two activities but I'm getting a NullPointerException where I
I'm storing some unstructured data (a keyed array) in one field of my table,
I have a problem in getting some data out from Cassandra using c# and
I have a Webserver running in Python. He is getting some Data from some

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.