/// <summary> /// Connect to database, but without synchronization /// </summary> /// <returns>True if opened</returns> internal bool ConnectWithoutSync() { #if EVAL if (license == null) { license = LicenseManager.Validate(typeof(VistaDBDatabase), this); } #endif if (databaseId > 0) { return(VistaDBAPI.ivdb_SelectDb(databaseId)); } try { databaseId = VistaDBAPI.ivdb_OpenDatabase(databaseName, "", exclusive, readOnly, (uint)parameters, password, (uint)cypher, false); clusterSize = VistaDBAPI.ivdb_GetClusterLength(); } catch (VistaDBException e) { if (!e.Critical) { databaseId = (int)(e.Result); } throw; } return(databaseId > 0); }
/// <summary> /// Clear low level data caching made by engine for database. /// </summary> public void ClearMemoryCache() { if (this.databaseId <= 0) { return; } lock (this.SyncRoot) { VistaDBAPI.ivdb_SelectDb(this.databaseId); VistaDBAPI.ivdb_ClearMemoryCache(); } }
/// <summary> /// Commit transaction /// </summary> /// <returns>Return true for success</returns> public bool CommitTransaction() { if (databaseId <= 0) { return(false); } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); return(VistaDBAPI.ivdb_CommitTransaction()); } }
/// <summary> /// Clear export\import list /// </summary> /// <returns>Return true if success else false</returns> public bool ClearExportList() { if (databaseId <= 0) { return(false); } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); return(VistaDBAPI.ivdb_ClearExportList()); } }
/// <summary> /// Export data from tables (in list) to xml-file /// </summary> /// <param name="cpXmlFileName">Xml-file name</param> /// <param name="OnlySchema">If true, then exports only schema else schema and data</param> /// <returns>Return true if success else false</returns> public bool ExportData(string cpXmlFileName, bool OnlySchema) { if (databaseId <= 0) { return(false); } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); return(VistaDBAPI.ivdb_ExportData(cpXmlFileName, OnlySchema)); } }
/// <summary> /// Space recycling mechanism status /// </summary> /// <returns>Return True if activated space recycling mechanism</returns> public bool ActivatedRecycling() { if (databaseId <= 0) { return(false); } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); return(VistaDBAPI.ivdb_ActivatedRecycling()); } }
/// <summary> /// Rollback transaction /// </summary> /// <param name="AllLevels">True for rollback all levels</param> public void RollbackTransaction(bool AllLevels) { if (databaseId <= 0) { return; } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); VistaDBAPI.ivdb_RollbackTransaction(AllLevels); } }
/// <summary> /// Saves in-memory table into /// </summary> /// <param name="databaseName">Database name</param> /// <returns></returns> public bool SaveToFile(string databaseName) { if (this.databaseId <= 0 || this.parameters != VDBDatabaseParam.InMemory) { return(false); } lock (this.SyncRoot) { VistaDBAPI.ivdb_SelectDb(this.databaseId); return(VistaDBAPI.ivdb_SaveToDatabase(databaseName)); } }
/// <summary> /// Check table existence /// </summary> /// <param name="tableName">Table name</param> /// <returns>Return true, if table exist, else false</returns> public bool IsTableExist(string tableName) { if (databaseId <= 0) { return(false); } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); return(VistaDBAPI.ivdb_IsTableExist(tableName)); } }
/////////////////////////////////////////////////////////////////////// ////////////////////////////////METHODS//////////////////////////////// /////////////////////////////////////////////////////////////////////// /// <summary> /// Activates space recycling mechanism /// </summary> public void ActivateRecycling() { if (databaseId <= 0) { return; } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); VistaDBAPI.ivdb_ActivateRecycling(); } }
public bool GetCaseSensitive() { if (databaseId <= 0) { return(false); } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); return(VistaDBAPI.ivdb_GetCaseSensitive()); } }
/// <summary> /// Import schema and data to current database /// </summary> /// <param name="cpXmlFileName">Xml-file name</param> /// <returns>Return true if success else false</returns> public bool ImportSchemaAndData(string cpXmlFileName) { if (databaseId <= 0) { return(false); } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); return(VistaDBAPI.ivdb_ImportSchemaAndData(cpXmlFileName)); } }
/// <summary> /// Flush database data buffers to disk /// </summary> public void FlushFileBuffers() { if (databaseId <= 0) { return; } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); VistaDBAPI.ivdb_FlushFileBuffers(); } }
/// <summary> /// Add table to XML export\import list /// </summary> /// <param name="cpTableName">Table name</param> /// <returns>Return true if success else false</returns> public bool AddToExportList(string cpTableName) { if (databaseId <= 0) { return(false); } lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); return(VistaDBAPI.ivdb_AddToExportList(cpTableName)); } }
/// <summary> /// Enum tables in the database /// </summary> /// <param name="list">Table names list</param> public void EnumTables(ref string[] list) { uint i; string sTableName; StringBuilder buf; string[] listTemp; if (databaseId <= 0) { return; } list = null; lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); buf = new StringBuilder(64); i = 0; do { i++; i = VistaDBAPI.ivdb_EnumTables(i, buf, 63); if (i != 0) { sTableName = VistaDBAPI.CutString(buf); if (list == null) { list = new string[1]; } else { listTemp = new string[list.Length + 1]; list.CopyTo(listTemp, 0); list = listTemp; } list[list.GetUpperBound(0)] = sTableName; } }while(i != 0); } }
internal void CloseWithoutSync() { if (databaseId > 0) { for (int i = 0; i < tableList.Count; i++) { ((VistaDBTable)tableList[i]).Close(); } VistaDBAPI.ivdb_SelectDb(databaseId); VistaDBAPI.ivdb_CloseDatabase(); databaseId = 0; } }
/// <summary> /// Drop table from database without using recycling. /// </summary> /// <param name="tableName">Table name</param> /// <returns>Return true for success</returns> public bool DropTableInstantly(string tableName) { if (databaseId > 0) { lock (SyncRoot) { VistaDBAPI.ivdb_SelectDb(databaseId); VistaDBAPI.ivdb_DropTableInstantly(tableName); return(true); } } else { return(false); } }
public VistaDBLocalConnection(int cultureID, bool caseSensitive) : this() { int dbID = VistaDBAPI.ivdb_CreateDatabase(null, null, false, false, (uint)cultureID, (uint)VDBDatabaseParam.InMemory, null, 0, caseSensitive); try { if (!VistaDBAPI.ivsql_AssignDatabaseConnection(this.connectionID, dbID, null, true, false, 0, null, caseSensitive)) { throw new VistaDBException(VistaDBErrorCodes.DatabaseNotOpened); } this.cultureID = cultureID; this.caseSensitivity = caseSensitivity; this.opened = true; } catch { VistaDBAPI.ivdb_SelectDb(dbID); VistaDBAPI.ivdb_CloseDatabase(); throw; } }