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. run project in network

run project in network

Scheduled Pinned Locked Moved C#
sysadmindatabasesql-serverhelp
15 Posts 8 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.
  • D Dalek Dave

    Flags. Set a flag on each record that indicates whether it is being edited or not. If the flag is 0 then editing allowed, if 1 then not. Once the edited record is completed, reset the flag to 0. Simples.

    ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

    J Offline
    J Offline
    jojoba2011
    wrote on last edited by
    #3

    THE Problem is that if client1 is editting the record and before ending the system of client1 restarts . So how can other edit that record.(in this solution this record cant be edit for ever....)

    D 1 Reply Last reply
    0
    • J jojoba2011

      Hi to codeproject world! i have a project with sql server 2008 which has a server and 5 client. [i mean that the project i have written is running on 6 pc's(one server and 5 client)] now my problem is when the client1 is editting a record ( for exm:- Id:12 , from table1 ) other 4 client and sever should not have permission to edit that record. hint : i send Id to sql and get record and then i start to edit. at that time i am not connected to sql..

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #4

      I would suggest reposting this question in the Database forum; this has very little to do with C#. AFAIK you can lock database records to do what you want; but I don't know the technical details, I expect someone in the Database forum knows the answer.

      I must get a clever new signature for 2011.

      D 1 Reply Last reply
      0
      • J jojoba2011

        THE Problem is that if client1 is editting the record and before ending the system of client1 restarts . So how can other edit that record.(in this solution this record cant be edit for ever....)

        D Offline
        D Offline
        Dalek Dave
        wrote on last edited by
        #5

        Thats an armageddon scenario. Why would the system restart? If it restarts without ending the edit, then the edit would be lost. You could put a time limit on open edited items, if not processed or closed within, say, 10 minutes, it closes automatically and resets the flag to 0.

        ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

        D 1 Reply Last reply
        0
        • L Lost User

          I would suggest reposting this question in the Database forum; this has very little to do with C#. AFAIK you can lock database records to do what you want; but I don't know the technical details, I expect someone in the Database forum knows the answer.

          I must get a clever new signature for 2011.

          D Offline
          D Offline
          Dalek Dave
          wrote on last edited by
          #6

          Good advice.

          ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

          1 Reply Last reply
          0
          • D Dalek Dave

            Thats an armageddon scenario. Why would the system restart? If it restarts without ending the edit, then the edit would be lost. You could put a time limit on open edited items, if not processed or closed within, say, 10 minutes, it closes automatically and resets the flag to 0.

            ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #7

            Yeah, and the flag would never get reset. What he wants just isn't really feasible to do and still have fault tolerance. One possible cause of a "failure" would be if Windows shutdown while the record was 'checked out' for edit.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            G 1 Reply Last reply
            0
            • J jojoba2011

              Hi to codeproject world! i have a project with sql server 2008 which has a server and 5 client. [i mean that the project i have written is running on 6 pc's(one server and 5 client)] now my problem is when the client1 is editting a record ( for exm:- Id:12 , from table1 ) other 4 client and sever should not have permission to edit that record. hint : i send Id to sql and get record and then i start to edit. at that time i am not connected to sql..

              D Offline
              D Offline
              dan sh
              wrote on last edited by
              #8

              As Richard suggested, this question suits better in the Database forum. You can make use of with(rowlock) in your update statement. This will help you avoiding multiple edits on the same row. You can also make use of rowversion to do this. I don't know much about rowversion way but someone in database forum should be able help with this.

              "Your code will never work, Luc's always will.", Richard MacCutchan[^]

              1 Reply Last reply
              0
              • J jojoba2011

                Hi to codeproject world! i have a project with sql server 2008 which has a server and 5 client. [i mean that the project i have written is running on 6 pc's(one server and 5 client)] now my problem is when the client1 is editting a record ( for exm:- Id:12 , from table1 ) other 4 client and sever should not have permission to edit that record. hint : i send Id to sql and get record and then i start to edit. at that time i am not connected to sql..

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #9

                and once you're in the Database forum, have a look at this thread[^]; I think it relates to what you want. :)

                Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                1 Reply Last reply
                0
                • D Dalek Dave

                  Flags. Set a flag on each record that indicates whether it is being edited or not. If the flag is 0 then editing allowed, if 1 then not. Once the edited record is completed, reset the flag to 0. Simples.

                  ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #10

                  Optimism is a great virtue, but not for a software developer... :(

                  Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                  1 Reply Last reply
                  0
                  • J jojoba2011

                    Hi to codeproject world! i have a project with sql server 2008 which has a server and 5 client. [i mean that the project i have written is running on 6 pc's(one server and 5 client)] now my problem is when the client1 is editting a record ( for exm:- Id:12 , from table1 ) other 4 client and sever should not have permission to edit that record. hint : i send Id to sql and get record and then i start to edit. at that time i am not connected to sql..

                    S Offline
                    S Offline
                    slam Iqbal
                    wrote on last edited by
                    #11

                    Hi, look at my Code. In my code DB_Command.Transaction = DB_Connection.BeginTransaction(System.Data.IsolationLevel.Serializable); defines transaction level. It locks(for update/insert) the database until the command is committed. Please never use flags.

                        public void Execute(string querystring)
                            {
                                DB\_Command = new OleDbCommand(querystring, DB\_Connection);
                                //DB\_Command.Transaction = DB\_Connection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);
                                DB\_Command.Transaction = DB\_Connection.BeginTransaction(System.Data.IsolationLevel.Serializable);
                                DB\_Command.CommandType = System.Data.CommandType.Text;
                                int afr=DB\_Command.ExecuteNonQuery();
                                DB\_Command.Transaction.Commit();
                            }
                    
                    J 1 Reply Last reply
                    0
                    • S slam Iqbal

                      Hi, look at my Code. In my code DB_Command.Transaction = DB_Connection.BeginTransaction(System.Data.IsolationLevel.Serializable); defines transaction level. It locks(for update/insert) the database until the command is committed. Please never use flags.

                          public void Execute(string querystring)
                              {
                                  DB\_Command = new OleDbCommand(querystring, DB\_Connection);
                                  //DB\_Command.Transaction = DB\_Connection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);
                                  DB\_Command.Transaction = DB\_Connection.BeginTransaction(System.Data.IsolationLevel.Serializable);
                                  DB\_Command.CommandType = System.Data.CommandType.Text;
                                  int afr=DB\_Command.ExecuteNonQuery();
                                  DB\_Command.Transaction.Commit();
                              }
                      
                      J Offline
                      J Offline
                      jojoba2011
                      wrote on last edited by
                      #12

                      Thanks for reply. But no use of these solutions.

                      1 Reply Last reply
                      0
                      • J jojoba2011

                        Hi to codeproject world! i have a project with sql server 2008 which has a server and 5 client. [i mean that the project i have written is running on 6 pc's(one server and 5 client)] now my problem is when the client1 is editting a record ( for exm:- Id:12 , from table1 ) other 4 client and sever should not have permission to edit that record. hint : i send Id to sql and get record and then i start to edit. at that time i am not connected to sql..

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #13

                        The best solution is to set a flag (with date/time) and check the flag before starting an edit session. If there is a possibility of a client not being able to reset the flag (ex: restart) before completing the edit, run a job in the background to check for flags that are open for the last x mins and reset those flags.

                        1 Reply Last reply
                        0
                        • D Dave Kreskowiak

                          Yeah, and the flag would never get reset. What he wants just isn't really feasible to do and still have fault tolerance. One possible cause of a "failure" would be if Windows shutdown while the record was 'checked out' for edit.

                          A guide to posting questions on CodeProject[^]
                          Dave Kreskowiak

                          G Offline
                          G Offline
                          Ganesh Kumar Kaki
                          wrote on last edited by
                          #14

                          Hi everyone, I'm also facing same kind of problem. Any help would be appreciate.

                          D 1 Reply Last reply
                          0
                          • G Ganesh Kumar Kaki

                            Hi everyone, I'm also facing same kind of problem. Any help would be appreciate.

                            D Offline
                            D Offline
                            Dave Kreskowiak
                            wrote on last edited by
                            #15

                            Then read the entire thread and figure out that what you want isn't really possible. You simply have to do research on "database concurrency" and pick the best option that fits your requirements.

                            A guide to posting questions on CodeProject[^]
                            Dave Kreskowiak

                            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