none
Compare and Update Table entries Linq RRS feed

  • Question

  • Hi,

    In my windows application using C#, I am reading an excel file containing columns and storing it into the database. The excel sheet contains a column called STATUS which includes (NOT STARTED , IN-PROGRESS , COMPLETE) several rows have different statuses. Everytime the excel sheet is read the values are stored into the table in the db. I have created tabs for each status, so that the data gets sorted out into the tabpages.

    Now in the latest excel sheet some of the rows have a changed status i.e a row which had STATUS as "NOT-STARTED" in the previous excel sheet, will now have status as "IN-PROGRESS". How do I compare this with the actual data in the database table and update that particular row with the new STATUS using LINQ. And also reflect the changes into my tabpages.




    Help appreciated,,,thanks
    Saturday, August 15, 2009 12:27 AM

Answers

  • ok git it to work though had to wait for a while.The trick is to use one data context for reading and making changes and call the submit changes once at the ends though beware that for long tables it can take a lot of time.

    dev
    • Marked as answer by Yichun_Feng Thursday, August 20, 2009 4:08 AM
    Sunday, August 16, 2009 3:07 PM

All replies

  • hi, i am facing a similar problem, i have to read a value from a table and then depending on what it is modify the other field in same table. I tried a couple of things but they all failed, i tried keep on changing the values for the field as the values are read from the same table after making comparisons and the call the submit changes once at the end but it seem to hang for ever. Then I tried using a separated data context and tried submitting the changes then and there after reading the field value from the first context but it failed also as it said that the first context must be closed before making changes using a new context for the same table.If nothing works a totally bs approach would be to cache all the changes in a local structure and once done with the values read from the table, start a new context or reuse the one and make the changes and submit the update, sounds silly but at the moment only choice for me, unless someone posts here a better solution. (btw i am using mySql)
    dev
    Sunday, August 16, 2009 3:57 AM
  • ok git it to work though had to wait for a while.The trick is to use one data context for reading and making changes and call the submit changes once at the ends though beware that for long tables it can take a lot of time.

    dev
    • Marked as answer by Yichun_Feng Thursday, August 20, 2009 4:08 AM
    Sunday, August 16, 2009 3:07 PM