public static void DropDatabase(string connectionString) { FbConnectionString options = new FbConnectionString(connectionString); options.Validate(); try { using (FbConnectionInternal db = new FbConnectionInternal(options)) { db.DropDatabase(); } } catch (IscException ex) { throw new FbException(ex.Message, ex); } }
public static void DropDatabase(string connectionString) { // Configure Attachment FbConnectionString options = new FbConnectionString(connectionString); options.Validate(); try { // Drop the database FbConnectionInternal db = new FbConnectionInternal(options); db.DropDatabase(); } catch (IscException ex) { throw new FbException(ex.Message, ex); } }
private static void CreateDatabaseImpl(string connectionString, int pageSize = 4096, bool forcedWrites = true, bool overwrite = false) { FbConnectionString options = new FbConnectionString(connectionString); options.Validate(); try { DatabaseParameterBuffer dpb = new DatabaseParameterBuffer(); dpb.Append(IscCodes.isc_dpb_version1); dpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 }); dpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { options.Dialect, 0, 0, 0 }); if (!string.IsNullOrEmpty(options.UserID)) { dpb.Append(IscCodes.isc_dpb_user_name, options.UserID); } if (options.Charset.Length > 0) { Charset charset = Charset.GetCharset(options.Charset); if (charset == null) { throw new ArgumentException("Character set is not valid."); } else { dpb.Append(IscCodes.isc_dpb_set_db_charset, charset.Name); } } dpb.Append(IscCodes.isc_dpb_force_write, (short)(forcedWrites ? 1 : 0)); dpb.Append(IscCodes.isc_dpb_overwrite, (overwrite ? 1 : 0)); if (pageSize > 0) { dpb.Append(IscCodes.isc_dpb_page_size, pageSize); } FbConnectionInternal db = new FbConnectionInternal(options); db.CreateDatabase(dpb); } catch (IscException ex) { throw new FbException(ex.Message, ex); } }
public static void CreateDatabase(string connectionString, int pageSize, bool forcedWrites, bool overwrite) { FbConnectionString options = new FbConnectionString(connectionString); options.Validate(); try { // DPB configuration DatabaseParameterBuffer dpb = new DatabaseParameterBuffer(); // Dpb version dpb.Append(IscCodes.isc_dpb_version1); // Dummy packet interval dpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 }); // User name dpb.Append(IscCodes.isc_dpb_user_name, options.UserID); // User password dpb.Append(IscCodes.isc_dpb_password, options.Password); // Database dialect dpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { options.Dialect, 0, 0, 0 }); // Character set if (options.Charset.Length > 0) { Charset charset = Charset.GetCharset(options.Charset); if (charset == null) { throw new ArgumentException("Character set is not valid."); } else { dpb.Append(IscCodes.isc_dpb_set_db_charset, charset.Name); } } // Forced writes dpb.Append(IscCodes.isc_dpb_force_write, (short)(forcedWrites ? 1 : 0)); // Database overwrite dpb.Append(IscCodes.isc_dpb_overwrite, (overwrite ? 1 : 0)); // Page Size if (pageSize > 0) { dpb.Append(IscCodes.isc_dpb_page_size, pageSize); } // Create the new database FbConnectionInternal db = new FbConnectionInternal(options); db.CreateDatabase(dpb); } catch (IscException ex) { throw new FbException(ex.Message, ex); } }