![]() ![]() Who is programmer - you or your cheef ? :)if your boss tell you such things - it meens he undestand nothing in programming. I know it's wrong.but my chief want this way.so i have to what he tell me. And you must not implement in your application logic like "let's see, if this row is locked, we will not read it" ! ![]() >does anyboby kwow if it's possible ti get the primary key of the record?It's possible to run SET LOCK_TIMEOUT 0 and if you gets error message it meens that row is locked, but do not do it :)It seems to me that you're going on the wrong way, you application doesn't need to care about all this stuff, it is the SQL Server responsibility to manage locking, all you need to do in your program is just to choose correct isolation level and try to keep your transactions as short as possible.Remember, architecture of mssql meens that transactions must wait on locks, this is NORMAL. Selecting the records is SharedLock.If that primary key is not used in any update or delete statements inside the transaction block, you can select itSee more on locks here to plan is Planning to fail if i run this script i have a table with the records locked but.i can get the name of the table withSELECT object_name(objid)as i get the name of the locked record's table does anyboby kwow if it's possible ti get the primary key of the record? ![]() Thanks a lot!!!CREATE TABLE #locks (spid int, dbid int, objid int, objectname sysname NULL, indid int, type char(4), resource char(15), mode char(10), status char(6))INSERT #locks (spid, dbid, objid, indid, type, resource, mode, status)EXEC dbo.sp_lockSELECT * FROM #locks where type='key'-DROP TABLE #lockswell. He must be waiting until your transaction is commited or rollbacked.Anyway, your question is a bit strange, because even if he would be able to get this information, what will he be doing ? :)by the way, it makes sense that you use not the repeatable read level but just hint "holdlock" or "updlock"SELECT * FROM dbtest with (holdlock) WHERE id_tag='2' >if a user run an UPDATE the application stands waiting until a commit or is impossible for another user to find out if a record is locked or not. Hi people i'm from italy and new here,first of all forgive my bad english.DATABASE: MSSQLAPPLICATION: WINFORM WRITTEN IN VB DOT.NET well this is my trouble i run a select on my table and i have to put a lock on the selected record.SELECT * FROM dbtest WHERE id_tag='2'so i set the isolation level at the transaction object in my code ODBCtransaction = ODBCconnection.BeginTransaction(IsolationLevel.RepeatableRead)and this run very good.only the user that runs this SELECT can UPDATE or DELETE this RECORDother user can only view this record and they can't update or delete this one.trouble:if a user run an UPDATE the application stands waiting until a commit or rollback.I DON'T WANT THISi have to undertand if the record IS LOCKEDHOW CAN I UNDERSTAND WITH A SELECT WHAT ARE THE RECORD LOCKED?THANK YOU! We've got lots of great SQL ServerĮxperts to answer whatever question you can come up with. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |