/// <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="DropDatabase(System.String)"]/*'/> 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); } }
/// <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="DropDatabase(System.String)"]/*'/> 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); } }
/// <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="CreateDatabase(System.String,System.Int32,System.Boolean,System.Boolean)"]/*'/> 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 }); // Database overwrite dpb.Append(IscCodes.isc_dpb_overwrite, (short)(overwrite ? 1 : 0)); // Character set if (options.Charset.Length > 0) { int index = Charset.SupportedCharsets.IndexOf(options.Charset); if (index == -1) { throw new ArgumentException("Character set is not valid."); } else { dpb.Append( IscCodes.isc_dpb_set_db_charset, Charset.SupportedCharsets[index].Name); } } // Page Size if (pageSize > 0) { dpb.Append(IscCodes.isc_dpb_page_size, pageSize); } // Forced writes dpb.Append(IscCodes.isc_dpb_force_write, (short)(forcedWrites ? 1 : 0)); if (!overwrite) { // Check if the database exists FbConnectionInternal c = new FbConnectionInternal(options); try { c.Connect(); c.Disconnect(); IscException ex = new IscException(IscCodes.isc_db_or_file_exists); throw new FbException(ex.Message, ex); } catch (FbException ex) { if (ex.ErrorCode != 335544344) { throw; } } } // Create the new database FbConnectionInternal db = new FbConnectionInternal(options); db.CreateDatabase(dpb); } catch (IscException ex) { throw new FbException(ex.Message, ex); } }
/// <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="CreateDatabase(System.String,System.Int32,System.Boolean,System.Boolean)"]/*'/> 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 }); // Database overwrite dpb.Append(IscCodes.isc_dpb_overwrite, (short)(overwrite ? 1 : 0)); // Character set if (options.Charset.Length > 0) { int index = Charset.SupportedCharsets.IndexOf(options.Charset); if (index == -1) { throw new ArgumentException("Character set is not valid."); } else { dpb.Append( IscCodes.isc_dpb_set_db_charset, Charset.SupportedCharsets[index].Name); } } // Page Size if (pageSize > 0) { dpb.Append(IscCodes.isc_dpb_page_size, pageSize); } // Forced writes dpb.Append(IscCodes.isc_dpb_force_write, (short)(forcedWrites ? 1 : 0)); if (!overwrite) { // Check if the database exists FbConnectionInternal c = new FbConnectionInternal(options); try { c.Connect(); c.Disconnect(); IscException ex = new IscException(IscCodes.isc_db_or_file_exists); throw new FbException(ex.Message, ex); } catch (FbException ex) { if (ex.ErrorCode != 335544344) { throw; } } } // Create the new database FbConnectionInternal db = new FbConnectionInternal(options); db.CreateDatabase(dpb); } catch (IscException ex) { throw new FbException(ex.Message, ex); } }