Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
My name is Sheetalkumar.

I have created one application in asp.net and uploaded into the server.

My problem is that when two users access my website at same time and click insert button then which is uploaded record by text file is insert into database together.

Means my record insert into his table and my record see his user.

Please please please help me
Posted
Updated 7-Nov-10 23:28pm
v2
Comments
PSK_ 8-Nov-10 5:17am    
Your query is not clear, can you explain it little more.
Dalek Dave 8-Nov-10 5:28am    
Improved as best I can.
Rajesh Anuhya 8-Nov-10 6:04am    
May be he is asking about the FileUpload control in ASP.net...

1 solution

It sounds like you are not managing your user sessions properly. It also sounds like you are saving stuff to a text file when you receive the information from the user. You have to virtually "lock" the text file when you receive a request from the user, write their data, and then release the lock again. If you receive a 2nd request while the file is locked, the 2nd user request will wait until the file is unlocked before performing the operation.

// This snippet is incomplete on purpose. How to implement it is yours to figure out. The locking is also not entirely complete.
bool isFileLocked = false;

codehandler( args )
{
   while( isFileLocked )
   {
       // Just wait for 25 milliseconds. Why? Why Not!!!
       System.Threading.Thread.Sleep( 250 );
   }
    if( !isFileLocked )
    {
        isFileLocked = true;
        // Do some stuff.
        isFileLocked = false;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900