我有以下代码:
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)ErrorCode = -2147168242 App 域名:/ LM / W3SVC / 819313558 / Root / ToolbarBackOffice-2-129804733861185000 级别:错误记录器:应用程序线程ID:1错误消息:迁移 来自:efrat96811@edokleinman.com到efrat98545@edokleinman.com faild, 会议来自:efrat96811@edokleinman.com资料来源:
TransactionException:事务已经隐式或 明确提交或中止。 AT:at System.Transactions.Oletx.OletxTransactionManager.ProxyException(收到COMException comException)at System.Transactions.TransactionInterop.GetExportCookie(交易 交易,Byte []行踪)at System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(交易 transaction,Byte [] whereAbouts)at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(交易 tx)at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(交易 交易) System.Data.ProviderBase.DbConnectionPool.GetConnection(的DbConnection 拥有对象) System.Data.ProviderBase.DbConnectionFactory.GetConnection(的DbConnection 拥有连接) System.Data.ProviderBase.DbConnectionClosed.OpenConnection(的DbConnection outerConnection,DbConnectionFactory connectionFactory)at System.Data.SqlClient.SqlConnection.Open()at Microsoft.Practices.EnterpriseLibrary.Data.Database.GetNewOpenConnection() 在 d:\管道\ RND \服务器\核心\开发\ Microsoft.Practices.EnterpriseLibrary.Data \ Database.cs:行 1168年 Microsoft.Practices.EnterpriseLibrary.Data.TransactionScopeConnections.GetConnection(数据库 db)in d:\管道\ RND \服务器\核心\开发\ Microsoft.Practices.EnterpriseLibrary.Data \ TransactionScopeConnections.cs:行 68点 Microsoft.Practices.EnterpriseLibrary.Data.Database.GetOpenConnection(布尔 disposeInnerConnection)in d:\管道\ RND \服务器\核心\开发\ Microsoft.Practices.EnterpriseLibrary.Data \ Database.cs:行 1194年 Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(的DbCommand 命令)in d:\管道\ RND \服务器\核心\开发\ Microsoft.Practices.EnterpriseLibrary.Data \ Database.cs:行 690在 CPUserInfrastructure.Services.CPUserService.MigrateInTrackingChannelsDbTable(GUID toSsoId,String ctid)in d:\管道\ RND \服务器\ SERVICES \ CPInfrastructure \ CPUserInfrastructure \ CPUserInfrastructure \ SERVICES \ CPUserService.cs:行 772在 CPUserInfrastructure.Services.CPUserService<> C_ DisplayClass8.b _7() 在 d:\管道\ RND \服务器\ SERVICES \ CPInfrastructure \ CPUserInfrastructure \ CPUserInfrastructure \ SERVICES \ CPUserService.cs:行 386在 CPInfrastructure.Helpers.TransactionHelpers.RunInTransaction(动作 逻辑) d:\管道\ RND \服务器\ SERVICES \ CPInfrastructure \ CPInfrastructure-DEV \助手\ TransactionHelpers.cs:行 17点 CPUserInfrastructure.Services.CPUserService.MigrateCPuserToolbar(GUID toSsoId,String ctid)in d:\管道\ RND \服务器\ SERVICES \ CPInfrastructure \ CPUserInfrastructure \ CPUserInfrastructure \ SERVICES \ CPUserService.cs:行 390在 BrandToolbar.Admin.ToolbarBackOffice.Toolbar.AccountsManagement.btnMTMigrate_Click(对象 发件人,EventArgs e)in d:\管道\ RND \服务器\ \网站已作家\开发,帐户-4.0 \ AdminServices \ Admin.Toolbar \集成\ BrandToolbar.Admin.ToolbarBackOffice \工具栏\ AccountsManagement.aspx.cs:行 142
COMException:事务已经隐式或 显式提交或中止(来自HRESULT的异常:0x8004D00E) AT:在System.Transactions.Oletx.ITransactionShim.Export(UInt32 whereaboutsSize,Byte []行踪,Int32& cookieIndex,UInt32& cookieSize,CoTaskMemHandle& cookieBuffer) System.Transactions.TransactionInterop.GetExportCookie(交易 交易,字节[]行踪)