当前位置: 首页>>代码示例>>C#>>正文


C# SqlCeEngine.Verify方法代码示例

本文整理汇总了C#中SqlCeEngine.Verify方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCeEngine.Verify方法的具体用法?C# SqlCeEngine.Verify怎么用?C# SqlCeEngine.Verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqlCeEngine的用法示例。


在下文中一共展示了SqlCeEngine.Verify方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: compactDatabase

        // Calls SQLCE's compactor
        public void compactDatabase()
        {
            string connString = @"Data Source = " + dbPath; // Create connection string for SQLCE DB
            SqlCeEngine engine = new SqlCeEngine(connString); // Instantiate engine object

            // Do the compaction
            engine.Compact(null);
            // We then verify the database, just incase.
            if (!engine.Verify())
            {
                throw new Exception("Database corrupt");
            }
        }
开发者ID:Sunstrike,项目名称:ASLib,代码行数:14,代码来源:ASComicDatabase.cs

示例2: EnsureDatabaseIntegrity

        /// <summary>
        /// Ensures the database integrity.
        /// </summary>
        /// <param name="systemId">The system id.</param>
        /// <param name="descriptor">The descriptor.</param>
        /// <param name="mode">The mode.</param>
        /// <exception cref="UnexpectedNHibernateConfigurationException">
        /// Unexpected dialect.
        /// or
        /// Unexpected connection driver.
        /// </exception>
        /// <exception cref="InvalidConfigurationException">
        /// Unable to find connection information in NHibernate Descriptor settings.
        /// or
        /// Unable to find data source in connection string.
        /// </exception>
        /// <exception cref="DatabaseVerificationErrorException"></exception>
        public virtual void EnsureDatabaseIntegrity(long systemId, Dictionary<string, string> descriptor, SchemaFactoryModeEnum mode)
        {
            if (descriptor == null)
            {
                ThrowHelper.ThrowArgumentNullException("descriptor");
            }

            if (descriptor.ContainsKey(DIALECT))
            {
                string dialect = descriptor[DIALECT];
                if (!dialect.StartsWith(DIALECT_EXPECTED_VALUE_BUILTIN) && !dialect.StartsWith(DIALECT_EXPECTED_VALUE_CUSTOM))
                {
                    throw new UnexpectedNHibernateConfigurationException("Unexpected dialect.");
                }
            }

            if (descriptor.ContainsKey(CONNECTION_DRIVER))
            {
                if (!CONNECTION_DRIVER_EXPECTED_VALUE.Equals(descriptor[CONNECTION_DRIVER]))
                {
                    throw new UnexpectedNHibernateConfigurationException("Unexpected connection driver.");
                }
            }

            string databaseFile = string.Empty;
            string connectionString = string.Empty;

            if (descriptor.ContainsKey(CONNECTION_STRING))
            {
                connectionString = descriptor[CONNECTION_STRING];
                databaseFile = GetDatabaseFile(connectionString);
            }
            else if (descriptor.ContainsKey(CONNECTION_STRING_NAME))
            {
                connectionString = ConfigurationManager.ConnectionStrings[descriptor[CONNECTION_STRING_NAME]].ConnectionString;
                databaseFile = GetDatabaseFile(connectionString);
            }
            else
            {
                throw new InvalidConfigurationException("Unable to find connection information in NHibernate Descriptor settings.");
            }

            if (string.IsNullOrEmpty(databaseFile))
            {
                throw new InvalidConfigurationException("Unable to find data source in connection string.");
            }

            using (SqlCeEngine en = new SqlCeEngine(connectionString))
            {
                FileInfo dbFileInfo = new FileInfo(databaseFile);
                if (!dbFileInfo.Exists)
                {
                    en.CreateDatabase();
                }
                else
                {
                    if (mode == SchemaFactoryModeEnum.Create || mode == SchemaFactoryModeEnum.Create_And_Drop)
                    {
                        dbFileInfo.Delete();
                        en.CreateDatabase();
                    }
                    else
                    {
                        if (!en.Verify(VerifyOption.Enhanced))
                        {
                            throw new DatabaseVerificationErrorException();
                        }
                    }
                }
            }
        }
开发者ID:JZO001,项目名称:Forge,代码行数:88,代码来源:SqlServerCe40Manager.cs

示例3: TryInstall

        public override InstallStatus TryInstall()
        {
            switch (_localConfig.Driver)
            {
                case SupportedNHDrivers.MsSqlCe4:
                    using (new WriteLockDisposable(SchemaValidationLocker))
                    {
                        using (var sqlCeEngine = new SqlCeEngine(_configuration.Properties[Environment.ConnectionString]))
                        {
                            if (!sqlCeEngine.Verify())
                            {
                                sqlCeEngine.CreateDatabase();
                            }
                        }
                    }
                    break;
            }

            InstallStatus installStatus;
            try
            {
                var schemaAlreadyValid = ValidateSchema(_configuration);
                if (schemaAlreadyValid) 
                    return new InstallStatus(InstallStatusType.Completed);
                UpdateSchema(_configuration);
                installStatus = new InstallStatus(InstallStatusType.Completed);
            }
            catch (Exception ex)
            {
                installStatus = new InstallStatus(InstallStatusType.TriedAndFailed, ex);
            }
            return installStatus;
        }
开发者ID:Joebeazelman,项目名称:rebelcmsxu5,代码行数:33,代码来源:ProviderBootstrapper.cs

示例4: Verify

 /// <summary>
 /// Recalculates the checksums for each page in the database and compares the new checksums to the expected values. Also verifies
 /// that each index entry exists in the table and that each table entry exists in the index. Applies only to SQL CE.
 /// </summary>
 /// <returns>
 /// 	<c>True</c> if there is no database corruption; otherwise, <c>false</c>.
 /// </returns>
 internal static bool Verify()
 {
     using (SqlCeEngine engine = new SqlCeEngine(Util.ConnectionString))
     {
         return engine.Verify(VerifyOption.Enhanced);
     }
 }
开发者ID:xusun,项目名称:GalleryServerPro,代码行数:14,代码来源:DataUtility.cs

示例5: VerifyDatabase

 public void VerifyDatabase(string connectionString)
 {
     using (SqlCeEngine engine = new SqlCeEngine(connectionString))
     {
         engine.Verify(VerifyOption.Enhanced);
     }
 }
开发者ID:inickvel,项目名称:SqlCeToolbox,代码行数:7,代码来源:SqlCeHelper.cs

示例6: verifyDatabase

        // Calls SQLCE's verification function
        public bool verifyDatabase()
        {
            string connString = @"Data Source = " + dbPath; // Create connection string for SQLCE DB
            SqlCeEngine engine = new SqlCeEngine(connString); // Instantiate engine object

            if (!engine.Verify())
            {
                throw new Exception("Database corrupt"); // Host application should use a try..catch block to catch this
            }

            return true; // Return true as Database is intact
        }
开发者ID:Sunstrike,项目名称:ASLib,代码行数:13,代码来源:ASComicDatabase.cs

示例7: Verify

        /// <summary>
        /// Recalculates the checksums for each page in the database and compares the new checksums to the expected values. Also verifies
        /// that each index entry exists in the table and that each table entry exists in the index.
        /// </summary>
        /// <returns>
        /// 	<c>True</c> if there is no database corruption; otherwise, <c>false</c>.
        /// </returns>
        public bool Verify()
        {
            using (var engine = new SqlCeEngine(ConnectionString))
            {
                return engine.Verify(VerifyOption.Enhanced);
            }

            // Same thing using Reflection:
            //object sqlCeEngine = null;
            //try
            //{
            //	sqlCeEngine = SqlCeEngineType.InvokeMember(null, BindingFlags.CreateInstance, null, null, new object[] { ConnectionString });

            //	var verifyOptionEnumType = SqlCeAssembly.GetType("System.Data.SqlServerCe.VerifyOption");

            //	var verifyOptionEnhanced = verifyOptionEnumType.GetField("Enhanced").GetValue(verifyOptionEnumType);

            //	var rv = SqlCeEngineType.InvokeMember("Verify", BindingFlags.InvokeMethod, null, sqlCeEngine, new[] { verifyOptionEnhanced });

            //	return Convert.ToBoolean(rv);
            //}
            //catch (TargetInvocationException ex)
            //{
            //	AppEventController.LogError(ex.InnerException ?? ex);
            //	throw;
            //}
            //finally
            //{
            //	if (sqlCeEngine != null)
            //		SqlCeEngineType.InvokeMember("Dispose", BindingFlags.InvokeMethod, null, sqlCeEngine, null);
            //}
        }
开发者ID:Jiyuu,项目名称:galleryserverpro,代码行数:39,代码来源:SqlCeController.cs


注:本文中的SqlCeEngine.Verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。