Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C#.Net

C#.Net

Scheduled Pinned Locked Moved C#
csharpdatabasexmltutorial
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ashwani_kumar
    wrote on last edited by
    #1

    Is its possible that two processes in a computer write the information Simultaneously in one XML file(test.XML) OR I have to use Database Please guide me if it is possible. Ashwani

    G 1 Reply Last reply
    0
    • A Ashwani_kumar

      Is its possible that two processes in a computer write the information Simultaneously in one XML file(test.XML) OR I have to use Database Please guide me if it is possible. Ashwani

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      I read some where that the XML classes prevent concurrent writes to an XML file. However, you will have other problems. For example, if user "A" modifies one part of the document and user "B" modifies another part, either user "A" or "B" will lose his\her modification dependent upon who wrote to the file last.

      A 1 Reply Last reply
      0
      • G George L Jackson

        I read some where that the XML classes prevent concurrent writes to an XML file. However, you will have other problems. For example, if user "A" modifies one part of the document and user "B" modifies another part, either user "A" or "B" will lose his\her modification dependent upon who wrote to the file last.

        A Offline
        A Offline
        Ashwani_kumar
        wrote on last edited by
        #3

        Thanks, My requirement is to only Insert the new records in a XML file( no modification, deletion) Ashwani

        G 1 Reply Last reply
        0
        • A Ashwani_kumar

          Thanks, My requirement is to only Insert the new records in a XML file( no modification, deletion) Ashwani

          G Offline
          G Offline
          George L Jackson
          wrote on last edited by
          #4

          You may loose inserted data too! 1. User A loads file. 2. User B loads file. 3. User A inserts data and saves it. 4. User B inserts data and saves it, and User A inserted data is lost.

          E 1 Reply Last reply
          0
          • G George L Jackson

            You may loose inserted data too! 1. User A loads file. 2. User B loads file. 3. User A inserts data and saves it. 4. User B inserts data and saves it, and User A inserted data is lost.

            E Offline
            E Offline
            emran834
            wrote on last edited by
            #5

            Right ! :) Ok ! I was thinking what about accessing SQL database by Two Threads simultaneously !! I am planning to do something like, [One thread is generating email address and email message and dump that record in SQL, another thread read email message from that SQL, send email and after that delete that record and scan any new record inserted] A) Thread A inserts record in SQL B) Thread B reads a record from SQL, may be the same one which was just inserted by Thread A. C) Thread B do some work based on the information of that record. D) Thread B Delete that record after finishing its work, and then look for new record again which was inserted by Thread A. ::: Now, Is there any chance of conflict ? I was worried about one thing, When Thread A is inserting record, does it lock the Database so that Thread B cannot read or delete any other record (not the exactly one which is being inserted) ? Or, When Thread B is reading or Deleting record, does it lock the database so that thread A cannot insert new record ? Thanks and regards... -- modified at 0:26 Thursday 23rd February, 2006

            P 1 Reply Last reply
            0
            • E emran834

              Right ! :) Ok ! I was thinking what about accessing SQL database by Two Threads simultaneously !! I am planning to do something like, [One thread is generating email address and email message and dump that record in SQL, another thread read email message from that SQL, send email and after that delete that record and scan any new record inserted] A) Thread A inserts record in SQL B) Thread B reads a record from SQL, may be the same one which was just inserted by Thread A. C) Thread B do some work based on the information of that record. D) Thread B Delete that record after finishing its work, and then look for new record again which was inserted by Thread A. ::: Now, Is there any chance of conflict ? I was worried about one thing, When Thread A is inserting record, does it lock the Database so that Thread B cannot read or delete any other record (not the exactly one which is being inserted) ? Or, When Thread B is reading or Deleting record, does it lock the database so that thread A cannot insert new record ? Thanks and regards... -- modified at 0:26 Thursday 23rd February, 2006

              P Offline
              P Offline
              Praveen Nayak
              wrote on last edited by
              #6

              If you were back to the xml file thing, you could have a common write function used by the two threads, and a lock(this) at the start of the function so that the other thread cannot execute that method when one thread is inside it. After every write into the file, you will have to save the file, so that when the next guy opens it, he will be appending to the already existing content of the xml file. There has to be more to life than just this

              E 1 Reply Last reply
              0
              • P Praveen Nayak

                If you were back to the xml file thing, you could have a common write function used by the two threads, and a lock(this) at the start of the function so that the other thread cannot execute that method when one thread is inside it. After every write into the file, you will have to save the file, so that when the next guy opens it, he will be appending to the already existing content of the xml file. There has to be more to life than just this

                E Offline
                E Offline
                emran834
                wrote on last edited by
                #7

                Hello, I understood about the XML file, but what about the SQL database file. Do i need to lock the database for similar operation ? Here I dont have multi user, but multi thread. I have two threads, one will insert record, another will read and delete record. at the same time, is there any chance of conflict and Hang ? Do I need to lock the database ?

                P 1 Reply Last reply
                0
                • E emran834

                  Hello, I understood about the XML file, but what about the SQL database file. Do i need to lock the database for similar operation ? Here I dont have multi user, but multi thread. I have two threads, one will insert record, another will read and delete record. at the same time, is there any chance of conflict and Hang ? Do I need to lock the database ?

                  P Offline
                  P Offline
                  Praveen Nayak
                  wrote on last edited by
                  #8

                  If you are using independent connections as suggested already earlier, it all comes down to whether the database maintains integrity of transactions. Yes it does, that is why we pay so much money to use an Oracle or SQL Server database. If thread A is inserting a row into the database, the concerned tables will be locked and thread B will be made to wait before it can read or delete stuff. So, yes, database is the most convinient method, albeit a tad slower. There has to be more to life than just this

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups