PDA

View Full Version : مشکل با تراکنش ها



aliila
شنبه 04 شهریور 1385, 08:56 صبح
من در برنامه تراکنشی را شروع میکنم به جدول اول یک رکورد اضافه میکنم و بعد به جدول دوم رکورد را اضافه میکنم و تراکنش را تایید میکنم تا اینجا درست کار میکند ام وقتی به دو مرحله فوق یک select هم اضافه کردم یعنی اول رکورد 1 را اضافه میکم بعد به جدول اول یک select میزنم تا مقداری را بدست آورم که در اضافه کردن رکورد 2 لازم خواهد بود با خطا متوقفم میشوم چرا ؟
در دلفی تراکنش فقط در insert , update عمل میکند و جدول را برای select قفل نمی کند

titbasoft
شنبه 04 شهریور 1385, 10:36 صبح
Isolation level ی پیش فرض ReadCommitted است که موجب بوجود اومدن این مشکل میشه، اون هم به علت Lock شدن رکوردهاست. شما می تونید از Isolation Level های دیگه استفاده کنید. برای اطلاعات بیشتر در مورد Isolation Level ها در دات نت:


ReadUncommitted: Does not lock the records being read. This means that an uncommitted change can be read and then rolled back by another client, resulting in a local copy of a record that is not consistent with what is stored in the database. This is called a dirty read because the data is inconsistent


Chaos: Behaves the same way as ReadUncommitted, but checks the isolation level of other pending transactions during a write operation so that transactions with more restrictive isolation levels are not overwritten


ReadCommitted: Locks the records being read and immediately frees the lock as soon as the records have been read. This prevents any changes from being read before they are committed, but it does not prevent records from being added, deleted, or changed by other clients during the transaction. This is the default isolation level


RepeatableRead: Locks the records being read and keeps the lock until the transaction completes. This ensures that the data being read does not change during the transaction


Serializable: Locks the entire data set being read and keeps the lock until the transaction completes. This ensures that the data and its order within the database do not change during the transaction

aliila
شنبه 04 شهریور 1385, 10:53 صبح
همگی را تست کردم ولی جواب نداد

titbasoft
شنبه 04 شهریور 1385, 11:13 صبح
اگر امکان داره پیام خطا به همراه کدتون رو اینجا کپی کنید.