gpt4 book ai didi

.net - 是否有SqlExceptions抛出但仍然提交其数据?

转载 作者:行者123 更新时间:2023-12-03 07:51:35 28 4
gpt4 key购买 nike

我最近遇到了错误:

System.Data.SqlClient.SqlException: The transaction log for database 'mydatabase' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases



在我的Windows服务之一上。它应该在捕获Sql异常后重试,我没想到的是,无论数据是否引发异常,数据似乎仍在通过中(我正在使用SqlBulkCopy btw)。我以前从未遇到过这种情况。

我想知道是否还有其他情况会发生这样的事情,并且首先是否完全有可能做到这一点?

编辑:

System.Data.UpdateException: An error occurred while updating the entries. See the InnerException for details. ---> System.Data.SqlClient.SqlException: The transaction log for database 'MY_DB' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary2 identifierValues, List1 generatedValues) at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) --- End of inner exception stack trace --- at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache) at System.Data.Objects.ObjectContext.SaveChanges(Boolean acceptChangesDuringSave) at System.Data.Objects.ObjectContext.SaveChanges()



PS。 如果有人知道上述异常的错误代码,那也会有很大帮助。

最佳答案

if this thing is entirely possible at all in the first place?



对的,这是可能的。在异常情况下,这取决于您的事务管理代码的作用。例如:
Connection connection = ConnectionFactory.create();

try {
DoWorkOn(connection);
}
catch (Exception e) {
Log.Message("SQL Problem", e);
}
finally {
connection.commit();
}

...总是会尝试提交。此行为内置于某些知名的事务管理库中(J2EE为应用程序异常指定了此行为)。

我对.NET不太熟悉-如果您发布了完整的堆栈跟踪,则可能有人会根据使用的事务管理软件为您提供更好的答案。

关于.net - 是否有SqlExceptions抛出但仍然提交其数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2735066/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com