Hi,
When a transaction is open, the database is getting locked for other user to fetch the records from database.
I have to update multiple database table with huge data (Lac). So the transaction will be open for longer period (some times hours).
Mean while if somebody tries to fetch or do select query it give timeout exception. And it does not function until the transaction is closed.
How to avoid this database locking for other users.
Below is the code that i have used:
using (DbConnection dbconn = base.db.CreateConnection())
{
dbconn.Open();
DbTransaction dbtran = dbconn.BeginTransaction();
try
{
Here inserting, updating to multiple table will be happening
dbtran.Commit();
}
catch (SqlException ex)
{
dbtran.Rollback();
}
finally
{
dbconn.Close();
}
}
Regards,
Hareesh Kumar
Enter your message below
Sign in or Join us (it's free).