locked
Determining size of database file RRS feed

  • Question

  • Is it possible to determine an exact size of database in Sql Server Compact? 

    My database is growing extremely fast. Once it reaches certain size, I want to create a new db and consume an old one.

    Currently I am considering following options:

    • Catching exception, however it is not of special type. It is always SqlCeException even for other type of errors. Analyzing message does not seem to be a good option.
    • Checking (new FileInfo('DbFileSize').Length). However it is not always accurate, and looks more like a work-around to me.

    Are there any better options available?


    Please remember to mark the replies as answers if they help
    Tuesday, July 12, 2011 9:43 AM

Answers

  • Thank you,

     In C# following code could be used to handle this exception

      try { .. code ..
          }
          catch (SqlCeException e) {
            foreach (SqlCeError error in e.Errors) {
              if (25104 == error.NativeError) { 
              }
            }
          }
    

    I have also found list of all other errors.


     


    Please remember to mark the replies as answers if they help
    • Marked as answer by ErikEJMVP Thursday, July 14, 2011 2:28 PM
    Thursday, July 14, 2011 12:32 PM

All replies

  • There is a specific exception for database szie too big, when the database reaches max database size

    25104

    SSCE_M_DATABASETOOBIG

    The database file is larger than the configured maximum database size.


    Please mark as answer, if this was it. Visit my SQL Server Compact blog

    Wednesday, July 13, 2011 6:37 AM
  • Thank you,

     In C# following code could be used to handle this exception

      try { .. code ..
          }
          catch (SqlCeException e) {
            foreach (SqlCeError error in e.Errors) {
              if (25104 == error.NativeError) { 
              }
            }
          }
    

    I have also found list of all other errors.


     


    Please remember to mark the replies as answers if they help
    • Marked as answer by ErikEJMVP Thursday, July 14, 2011 2:28 PM
    Thursday, July 14, 2011 12:32 PM