run project in network
-
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..
-
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..
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[^]
-
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[^]
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....)
-
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..
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.
-
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....)
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[^]
-
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.
-
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[^]
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 -
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..
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[^]
-
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..
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.
-
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[^]
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.
-
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..
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 thecommand
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(); }
-
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 thecommand
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(); }
Thanks for reply. But no use of these solutions.
-
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..
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.
-
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 KreskowiakHi everyone, I'm also facing same kind of problem. Any help would be appreciate.
-
Hi everyone, I'm also facing same kind of problem. Any help would be appreciate.
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