SIVAKUMAR.J
SIVAKUMAR.J

Reputation: 4354

More than one application able to access the same database in SQL Server at a same time?

I'm very new to .NET, C# and SQL Server.

I need to develop a socket application using C#. That application should insert, delete, update, etc the data in database with respect to some request.

I need to develop another windows service application using C# that sends the data in the database to the web application through http.

The both applications run in the same system. The database is SQL Server. Both the applications use the same database.

I am unsure if while one application is deleting or inserting data in the database, then is the other application still able to access the database at a same time.

Upvotes: 2

Views: 4039

Answers (3)

bryanmac
bryanmac

Reputation: 39296

Sql Server can handle multiple requests just fine. Each connected client gets a different spid.

However, it is up to your sql server code (batches or sprocs) to handle data conceurrency issues via isolation levels and transactions. So in order to control one user reading data while others are updating, deleting etc..., you need to use isolation levels and locks.

Isolation levels:

http://msdn.microsoft.com/en-us/library/aa213034(v=sql.80).aspx

Also: http://dbalink.wordpress.com/2008/05/27/isolation-levels-and-locks-in-sql-server-2005/

Good writeup on transactions:

https://web.archive.org/web/20210614153200/http://aspnet.4guysfromrolla.com/articles/072705-1.aspx

Upvotes: 3

ElDog
ElDog

Reputation: 1377

It is possible to access the same sql server database by as many applications as you want. If you are afraid that one application can attempt to read the data being changed by another one at the same time, read about transactions and isolation. But in very short, if you make a small atomic change which requires one line of sql code only, you probably shouldn't care about this at the moment.

Upvotes: 0

Paddy
Paddy

Reputation: 33857

I think that the simple answer is yes - multiple applications/people can access a database at the same time.

You may want to read up on transactions within a database and concurrency:

http://en.wikipedia.org/wiki/Atomicity_(database_systems)

http://msdn.microsoft.com/en-us/library/cs6hb8k4(v=vs.80).aspx

Upvotes: 0

Related Questions