C# 数据库文件大于配置的最大数据库大小。这是什么意思?
您好,我在更新sql compact数据库时有时会遇到此异常。 错误如下:C# 数据库文件大于配置的最大数据库大小。这是什么意思?,c#,sql,database,C#,Sql,Database,您好,我在更新sql compact数据库时有时会遇到此异常。 错误如下: 2/6/2017 11:06:08 AM ERROR IN SavePacket(EnergyMeter_Grid e) data into file System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
2/6/2017 11:06:08 AM ERROR IN SavePacket(EnergyMeter_Grid e) data into file
System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.SqlServerCe.SqlCeException: The database file is larger than the configured maximum database size. This setting takes effect on the first concurrent database connection only. [ Required Max Database Size (in MB; 0 if unknown) = 21 ]
at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
at System.Data.Entity.SqlServerCompact.SqlCeMultiCommand.ExecuteNonQuery()
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
--- End of inner exception stack trace ---
at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
at System.Data.Entity.Internal.InternalContext.SaveChanges()
--- End of inner exception stack trace ---
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at ILS.DB.DbUpdateLoop.SavePacket(EnergyMeter_Grid e)
我知道这可能是大小的原因,因为前几天我手动将我的数据库大小设置为4GB
using (var context = Context.Create("C:\\XSR_BIB_V2\\XSR_BIB_V2_DATABASE.sdf", "", 4091))
{
if (DbUpdateLoop.context.Database.Connection.State == System.Data.ConnectionState.Closed)
DbUpdateLoop.context.Database.Connection.Open();
}
这个异常不会对我的功能产生太大影响,但我很好奇可能会出什么问题。此异常通常发生在名为SavePacket(EnergyMeter\u Grid e)
的位置,如上面的异常日志所示
存储包(能量表网格e)代码:
代码说明:很简单,我所做的只是打开一个上下文,将energyMeter_gridtable值作为参数转换为sql compact db并保存更改
would love if someone one tell me why this error is happening and what should i do to resolve it??
您是否已将max db sizeYes i配置为4091-(4gb)以便准确。您使用了哪个SQL CE版本?首先检查此DB size参数说明:,然后尝试在SDF连接字符串中使用size参数:
Data Source=[Database Name].SDF;最大数据库大小=4096
我正在使用的Hi版本4.0。限额是4091。我应该提到上面这个例外,我偶尔会遇到一次,可能是一天一次左右。你的实际数据库大小是否超过了4091MB的限制?尝试使用Shrink
()和Compact
()压缩数据库大小。
would love if someone one tell me why this error is happening and what should i do to resolve it??