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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:40:33+00:00 2026-06-05T11:40:33+00:00

Ive been working on a program that allows me to updload data from my

  • 0

Ive been working on a program that allows me to updload data from my sql server DB into a SOAP service. I can successfully upload the data into the service. The problem is that the same row is being inserted. The following is a part of my code: `

            List<service1.SDataRow> ArrayOfSData = new List<ne_service_demo2.service1.SDataRow>();
               //data to be uploaded. 
                    service1.SDataRow row1 = new service1.SDataRow();
                    foreach (DataRow dRow in dTable.Rows)
                    {

                         row1.SensorTimeStamp = dRow["SensorTimeStamp"].ToString();
                         row1.SensorID = dRow["SensorID"].ToString();
                         row1.PercentFull = dRow["PercentFull"].ToString();
                         row1.Temp = dRow["Temp"].ToString();
                         row1.TempReading = dRow["TempReading"].ToString();
                         row1.Sig = dRow["Sig"].ToString();
                         row1.SignalReading = dRow["SignalReading"].ToString();
                         row1.Noi = dRow["Noi"].ToString();
                         row1.NoiseReading = dRow["NoiseReading"].ToString();
                         row1.Cou = dRow["Cou"].ToString();
                         row1.CountReading = dRow["CountReading"].ToString();
                         row1.NewPercentFull = dRow["NewPercentFull"].ToString();
                         row1.Current_Gallons_In_Tank = dRow["Current_Gallons_In_Tank"].ToString();
                         ArrayOfSData.Add(row1);                                                       
                    }

                    service1.SensorData sd = new service1.SensorData();
                    sd.API_ACCESS_KEY = "7e070c1981ccc368483a207801be17aa17b2334c";
                    sd.AccountCode = "0000000";
                    sd.SData = ArrayOfSData.ToArray();

                    // Asynchronous call
                    ws.PostSensorDataCompleted += WebSeviceResult;
                    ws.PostSensorDataAsync(sd);`

As I loop through my DB table, all data goes to the appropriate fields or columns. Again, the problem is that I get the same row x amount of times. I know the problem is “row1” because it is constantly being updated with new values while still keeping the list count. However, I can not make row1 a list type because it must be of SDataRow type since that is the class that links my service to the columns of my DB. I also tried using the List.Clear() method to clear out my list within my loop but did not work. When I tried clearing the list after every iteration I would get an error saying “Item has already been added.” So in theory the clear() method should work, its the row1 that is causing problems. Does anyone know of a work around or a way to make

  • 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-05T11:40:34+00:00Added an answer on June 5, 2026 at 11:40 am

    You are creating an instance of the SDataRow outside the loop. Inside the loop, you are setting the properties of that same instance (overwriting them each iteration), then adding that same instance to the list.

    Change that part of the code to this:

      foreach (DataRow dRow in dTable.Rows)
      {
          service1.SDataRow row1 = new service1.SDataRow();
    

    So you need to create new instances inside the foreach loop

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

Sidebar

Related Questions

I've been working on a program that converts numbers into binary. As you can
I've been busy working on a program that can solve Minesweeper puzzles (for no
I've been working on a program that visually outputs the contents of a binary
I've been working on a weather forecaster for a program that I use, and
I've been working on a small and simple program that I drop files onto
I've been working on a program that is supposed to output the winning status
So in the text editor program that i've been working on, I've used WM_CHAR
I've been working on a program in C# that involves image editing and animating.
hey ive been working with GLM and i have been noticing that im not
I'm quite new into the programming game, I've been working on this program for

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.