【发布时间】:2011-01-04 19:57:32
【问题描述】:
我有以下方法:
public void SaveReferenceUpdates(ReferenceUpdatesDataContract updates)
{
mTransaction = Connection.BeginTransaction();
try
{
// Do all the updates to get the database inline with the contract.
updates.UpdateFromContract();
// Do all the deletes to get the database inline with the contract.
updates.DeletesFromContract();
try{mTransaction.Commit();}
catch{throw;}
mTransaction = null;
}
catch (Exception e)
{
mTransaction.Rollback();
mTransaction = null;
throw;
}
}
(我已取出所有日志记录语句并折叠了一些方法以使其更具可读性。)
奇怪的是,有时(非常随机地)mTransaction 在进入提交步骤时为空。 (由于这种情况发生得如此随机,所以当它从连接中获取事务时,我无法查看它是否为空。)
这个方法在两个地方被调用。一种是用户登录我的应用程序时,另一种是用户一段时间不活动时(基于关闭用户输入的计时器)。
我不知道什么可能导致 SqlCeTransaction (mTransaction) 永远为空。 (帮助没有说明 BeginTransaction 返回null。)
【问题讨论】:
标签: windows-mobile compact-framework sql-server-ce windows-mobile-6.5