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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:33:10+00:00 2026-06-08T06:33:10+00:00

I have a table which has some 100-200 records. I have fetch those records

  • 0

I have a table which has some 100-200 records.
I have fetch those records into a dataset.

Now i am looping through all the records using foreach

dataset.Tables[0].AsEnumerable()

I want to update a column for each record in the loop. How can i do this. Using the same dataset.

  • 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-08T06:33:11+00:00Added an answer on June 8, 2026 at 6:33 am

    I’m Assumng your using a Data Adapter to Fill the Data Set, with a Select Command?

    To edit the data in your Data Table and save changes back to your database you will require an Update Command for you Data Adapter. Something like this :-

    SQLConnection connector = new SQLConnection(@"Your connection string");
    
    SQLAdaptor Adaptor = new SQLAdaptor();
    
    Updatecmd = new sqlDbCommand("UPDATE YOURTABLE SET FIELD1= @FIELD1, FIELD2= @FIELD2   WHERE ID = @ID", connector);
    

    You will also need to Add Parameters for the fields :-

    Updatecmd.Parameters.Add("@FIELD1", SQLDbType.VarCHar, 8, "FIELD1");
    Updatecmd.Parameters.Add("@FIELD2", SQLDbType.VarCHar, 8, "FIELD2");
    
    var param = Updatecmd.Parameters.Add("@ID", SqlDbType.Interger, 6, "ID");
    param.SourceVersion = DataRowVersion.Original;
    

    Once you have created an Update Command with the correct SQL statement, and added the parameters, you need to assign this as the Insert Command for you Data Adapter :-

    Adaptor.UpdateCommand = Updatecmd;
    

    You will need to read up on doing this yourself, go through some examples, this is a rough guide.

    The next step is to Enumerate through your data table, you dont need LINQ, you can do this :-

      foreach(DataRow row in Dataset.Tables[0].Rows)
        {
            row["YourColumn"] = YOURVALUE;
        }
    

    One this is finished, you need to call the Update() method of yout Data Adapter like so :-

    DataAdapter.Update(dataset.Tables[0]);
    

    What happens here, is the Data Adapter calls the Update command and saves the changes back to the database.

    Please Note, If wish to ADD new rows to the Database, you will require am INSERT Command for the Data Adapter.

    This is very roughly coded out, from the top of my head, so the syntax may be slightly out. But will hopefully help.

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

Sidebar

Related Questions

I have an access table which has some cells as blank ( no data
I have a data table which already has some values, plus it is getting
I have a table on a iSeries(IBM-i/AS400) which has some constraints. The table is
i have a table which has many fields but i want to get count
I have a table which has a field called Sold , in that field
I have a table which has several one to many relationships with other tables.
I have a table which has two text boxes and an image beside it
I have a table which has employee relationship defined within itself. i.e. EmpID Name
I have a table which has essentially boolean values in a legacy database. The
I have a table which has a column called Direct of type char(1). It's

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.