Ejemplo n.º 1
0
        /// <summary>
        /// Create new database
        /// </summary>
        /// <param name="iCultureId">Culture ID for database</param>
        /// <param name="bOpenAfterCreation">If true then database opens after creation</param>
        /// <param name="bCaseSensitivity">Sets case-sensitivity flag for character data in run-time searching and filtering operations. Used as respective flag in primary and FTS indexes</param>
        /// <returns>return true for success</returns>
        public bool CreateDatabase(int iCultureId, bool bOpenAfterCreation, bool bCaseSensitivity)
        {
            bool res;
            int  tmp;

            if (bOpenAfterCreation && databaseId > 0)
            {
                throw new VistaDBException(VistaDBErrorCodes.DatabaseMustBeClosedBeforeCreate);
            }

            lock (SyncRoot)
            {
                VistaDBAPI.ivdb_SetClusterLength(clusterSize);
                //Parameters bExclusive and bReadOnly are not used by Engine
                tmp = VistaDBAPI.ivdb_CreateDatabase(databaseName, "", true, false, (uint)iCultureId, (uint)parameters,
                                                     password, (uint)cypher, bCaseSensitivity);
                VistaDBAPI.ivdb_SetClusterLength(1);

                if (tmp > 0)
                {
                    if (parameters != VDBDatabaseParam.InMemory)
                    {
                        VistaDBAPI.ivdb_CloseDatabase();

                        if (bOpenAfterCreation)
                        {
                            res = ConnectWithoutSync();
                        }
                        else
                        {
                            res = true;
                        }
                    }
                    else
                    {
                        databaseId = tmp;
                        res        = true;
                    }
                }
                else
                {
                    res = false;
                }

                return(res);
            }
        }