kumar.chaudhari26-gmail
-
2/22/2012 1:20:01 AM
lock(object) in chsarp.net
Hello every one,
I am developing a web page with asp.net csharp
i have a code which is critical . i want only one user to access that section of code at a time.
i have used the following code
string doc_number = ""; try { lock (lock1) {
doc_number = PostSalaryToSAP();
// doc_number = ""; if (doc_number.Length > 6) { this.Result.Text = "Posting Successful For Employee id '" + cbEmpID.SelectedItem.Text.ToString() + "' With Doc_number : " + doc_number; this.Result.ForeColor = System.Drawing.Color.Green; this.btnPost.Enabled = false; this.btnDelete.Enabled = false; } else { this.Result.Text = "Posting Failed "; this.Result.ForeColor = System.Drawing.Color.Green; } } } catch (Exception ex1) { Result.Text = "Posting Unsuccessful "; Result.ForeColor = System.Drawing.Color.Green; }
but with this code this results are not getting generated properly.
Normally
doc_number = PostSalaryToSAP(); this line adds a single record to db table.
but Using this code it adds 2 rows.
what is is the actual issue i am not able to understand please help
|