By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,594 Members | 3,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,594 IT Pros & Developers. It's quick & easy.

transaction and open table

P: n/a
Hi,

I have few db write and read to execute, so I use transaction.

Is that a problem or is that a regular way that I only use transaction on
some cmds only, and other cmds I do not use trasaction, esp those read
actions, or even use another dbconnection to read?

BTW, what does "open table" menas? Is that table only be "open" when someone
read or write it. Once all user finish read or write the db table, the
table should be "closed", is that right?

Thanks a lot!
R L

Jun 24 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Ryan Liu" <Ry********@yahoo.comwrote in message
news:el**************@TK2MSFTNGP04.phx.gbl...
I have few db write and read to execute, so I use transaction.

Is that a problem or is that a regular way that I only use transaction on
some cmds only, and other cmds I do not use trasaction, esp those read
actions, or even use another dbconnection to read?
It depends on what you are trying to accomplish. If the transaction is
properly isolated (which you control through the transaction isolation
level), then those commands that you execute outside of the transaction will
not see the changes that you have done inside the transaction until the
transaction is committed. This may or may not be what you want to happen.
Moreover, since the transaction will place locks on the database to
accomplish the isolation, depending on what you are doing you risk that the
database commands that you are executing outside of the transaction might
get blocked waiting for the transaction to finish. You certainly don't want
this to happen, because the blocked command would stop your program from
proceeding to complete the transaction, and therefore would never get
unblocked.

BTW, what does "open table" menas? Is that table only be "open" when
someone
read or write it. Once all user finish read or write the db table, the
table should be "closed", is that right?
If you are sending Sql commands to a database, then the tables are not
'open' or 'closed'. They simply get some locks placed upon them when they
are accessed inside a transaction, and the locks are removed when the
transaction completes. This is automatic, and you don't have to do anything
special for it to happen.

Jun 24 '07 #2

P: n/a

"Ryan Liu" <Ry********@yahoo.comwrote in message
news:el**************@TK2MSFTNGP04.phx.gbl...
Hi,

I have few db write and read to execute, so I use transaction.

Is that a problem or is that a regular way that I only use transaction on
some cmds only, and other cmds I do not use trasaction, esp those read
actions, or even use another dbconnection to read?
The only time you need to be in a transactional mode is when you are
updating, inserting or deleting records using a database table.
>
BTW, what does "open table" menas? Is that table only be "open" when
someone
read or write it. Once all user finish read or write the db table, the
table should be "closed", is that right?
Yes, once the access is completed, then the connection should be closed and
disposed, each time after the access.

http://www.sql-server-performance.co...ansactions.asp

You should use Google and look up the ADO.NET *Using* statement that
opens/closes/disposes things for you automatically.

Jun 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.