我有以下代码:
private void MigrateInTrackingChannelsDbTable(Guid toSsoId, string ctid)
{
Database database = DatabaseFactory.CreateDatabase("TrackingChannels");
try
{
using (DbCommand command = database.GetStoredProcCommand("usp_TrackingChannels_MigrateToolbar"))
{
database.AddInParameter(command, "@ToSSOId", DbType.Guid, toSsoId);
database.AddInParameter(command, "@CTID", DbType.String, ctid);
database.ExecuteNonQuery(command);
}
}
catch (Exception ex)
{
Log.Application.Error(
string.Format("CPUserService: MigrateInTrackingChannelsDbTable failed with toSsoId:{0}, ctid:{1}", toSsoId, ctid), ex);
throw;
}
}
但得到以下错误:
System.Transactions.TransactionException:事务已被隐式或显式提交或中止。System.Runtime.InteropServices.COMException:事务已被隐式或显式提交或中止(来自 HRESULT 的异常:0x8004D00E)错误代码 = -2147168242 应用程序域:/LM/W3SVC/819313558/Root/ToolbarBackOffice-2-129804733861185000 级别:错误记录器:应用程序线程 ID:1 错误消息:从 efrat96811@edokleinman.com 迁移到 efrat98545@edokleinman.com 失败,会话来自:efrat96811@edokleinman.com 来源:
TransactionException:事务已被隐式或显式提交或中止。AT:在 System.Transactions.Oletx.OletxTransactionManager.ProxyException(COMException comException) 在 System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] 下落) 在 System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(Transaction transaction, Byte[] whereAbouts) 在 System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction) 在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) 在 System.Data.ProviderBase 的 System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx) System.Data.ProviderBase.DbConnectionClosed 处的 .DbConnectionFactory.GetConnection(DbConnection owningConnection)。显示类8.bD:\Conduit\RnD\Server\Services\CPInfrastructure\CPUserInfrastructure\CPUserInfrastructure\Services\CPUserService.cs 中的 _7():D:\Conduit\RnD\Server 中 CPInfrastructure.Helpers.TransactionHelpers.RunInTransaction(动作逻辑)的第 386 行\Services\CPInfrastructure\CPInfrastructure-Dev\Helpers\TransactionHelpers.cs:D:\Conduit\RnD\Server\Services\CPInfrastructure\CPUserInfrastructure\CPUserInfrastructure\ 中 CPUserInfrastructure.Services.CPUserService.MigrateCPuserToolbar(Guid toSsoId,String ctid)的第 17 行Services\CPUserService.cs:D:\Conduit\RnD\Server\WebSites\Writers\Dev-Accounts-4.0\AdminServices\Admin 中 BrandToolbar.Admin.ToolbarBackOffice.Toolbar.AccountsManagement.btnMTMigrate_Click(Object sender, EventArgs e) 的第 390 行.Toolbar\Integration\BrandToolbar.Admin.ToolbarBackOffice\Toolbar\AccountsManagement.aspx.cs:第 142 行
COMException:事务已被隐式或显式提交或中止(来自 HRESULT 的异常:0x8004D00E)AT:在 System.Transactions.Oletx.ITransactionShim.Export(UInt32 whereaboutsSize,Byte[] whereabouts,Int32& cookieIndex,UInt32& cookieSize,CoTaskMemHandle& cookieBuffer)在 System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] 行踪)