public void CreateDropDatabaseUsingTrustedAuth() { if (WireCrypt == FbWireCrypt.Required) { return; } if (!EnsureServerType(FbServerType.Default)) { return; } if (GetServerVersion() >= new Version(3, 0, 0, 0)) { using (var cmd = Connection.CreateCommand()) { cmd.CommandText = "create or alter global mapping admin_trusted_auth using plugin win_sspi from any user to role rdb$admin"; cmd.ExecuteNonQuery(); } } try { var csb = BuildConnectionStringBuilder(FbServerType, Compression, WireCrypt); csb.UserID = string.Empty; csb.Password = string.Empty; csb.Database = $"{Guid.NewGuid().ToString()}.fdb"; var cs = csb.ToString(); Assert.DoesNotThrow(() => FbConnection.CreateDatabase(cs, overwrite: true)); Assert.DoesNotThrow(() => FbConnection.DropDatabase(cs)); } finally { if (GetServerVersion() >= new Version(3, 0, 0, 0)) { using (var cmd = Connection.CreateCommand()) { cmd.CommandText = "drop global mapping admin_trusted_auth"; cmd.ExecuteNonQuery(); } } } }
private void drop_Click(object sender, EventArgs e) { var result = MessageBox.Show("Are you sure to drop the " + path.Database + " Database", "Question", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { try { con.Close(); con.Close(); FbConnection.ClearAllPools(); FbConnection.DropDatabase(path.ToString()); Tools t = new Tools(); t.Close(); MessageBox.Show("Database " + path.Database + " has been removed", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Database file was not found on the host. Please connect to a Database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public virtual void Generate(FbDropDatabaseOperation operation, IModel model, MigrationCommandListBuilder builder) { FbConnection.ClearAllPools(); FbConnection.DropDatabase(operation.ConnectionStringBuilder.ToString()); }
/// <summary> /// Starts the ordered execution of the SQL statements that are in <see cref="SqlStatements"/> collection. /// </summary> /// <param name="autoCommit">Specifies if the transaction should be committed after a DDL command execution</param> public void Execute(bool autoCommit) { if (this.SqlStatements == null || this.SqlStatements.Count == 0) { throw new InvalidOperationException("There are no commands for execution."); } foreach (string sqlStatement in this.SqlStatements) { if (string.IsNullOrEmpty(sqlStatement)) { continue; } // initializate outputs to default int rowsAffected = -1; FbDataReader dataReader = null; SqlStatementType statementType = FbBatchExecution.GetStatementType(sqlStatement); if (!(statementType == SqlStatementType.Connect || statementType == SqlStatementType.CreateDatabase || statementType == SqlStatementType.Disconnect || statementType == SqlStatementType.DropDatabase || statementType == SqlStatementType.SetDatabase || statementType == SqlStatementType.SetNames || statementType == SqlStatementType.SetSQLDialect)) { // Update command configuration this.ProvideCommand(); this.sqlCommand.CommandText = sqlStatement; // Check how transactions are going to be handled if (statementType == SqlStatementType.Insert || statementType == SqlStatementType.Update || statementType == SqlStatementType.Delete) { // DML commands should be inside a transaction if (this.sqlTransaction == null) { this.sqlTransaction = this.sqlConnection.BeginTransaction(); } this.sqlCommand.Transaction = this.sqlTransaction; } else if (this.sqlTransaction != null && !(statementType == SqlStatementType.Commit || statementType == SqlStatementType.Rollback)) { // Non DML Statements should be executed using // implicit transaction support this.sqlTransaction.Commit(); this.sqlTransaction = null; } } try { switch (statementType) { case SqlStatementType.AlterDatabase: case SqlStatementType.AlterDomain: case SqlStatementType.AlterException: case SqlStatementType.AlterIndex: case SqlStatementType.AlterProcedure: case SqlStatementType.AlterTable: case SqlStatementType.AlterTrigger: case SqlStatementType.AlterView: // raise the event this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(this.sqlCommand, autoCommit); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.Commit: // raise the event this.OnCommandExecuting(null); this.sqlTransaction.Commit(); this.sqlTransaction = null; // raise the event this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.Connect: // raise the event this.OnCommandExecuting(null); this.ConnectToDatabase(sqlStatement); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.CreateDatabase: // raise the event this.OnCommandExecuting(null); this.CreateDatabase(sqlStatement); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.CommentOn: case SqlStatementType.CreateDomain: case SqlStatementType.CreateException: case SqlStatementType.CreateGenerator: case SqlStatementType.CreateIndex: case SqlStatementType.CreateProcedure: case SqlStatementType.CreateRole: case SqlStatementType.CreateSequence: case SqlStatementType.CreateShadow: case SqlStatementType.CreateTable: case SqlStatementType.CreateTrigger: case SqlStatementType.CreateView: case SqlStatementType.DeclareCursor: case SqlStatementType.DeclareExternalFunction: case SqlStatementType.DeclareFilter: case SqlStatementType.DeclareStatement: case SqlStatementType.DeclareTable: case SqlStatementType.Delete: // raise the event this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(this.sqlCommand, autoCommit); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.Describe: break; case SqlStatementType.Disconnect: // raise the event this.OnCommandExecuting(null); this.sqlConnection.Close(); FbConnection.ClearPool(this.sqlConnection); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.DropDatabase: // raise the event this.OnCommandExecuting(null); FbConnection.DropDatabase(this.connectionString.ToString()); //this.sqlConnection = null; this.requiresNewConnection = true; // raise the event this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.DropDomain: case SqlStatementType.DropException: case SqlStatementType.DropExternalFunction: case SqlStatementType.DropFilter: case SqlStatementType.DropGenerator: case SqlStatementType.DropIndex: case SqlStatementType.DropProcedure: case SqlStatementType.DropSequence: case SqlStatementType.DropRole: case SqlStatementType.DropShadow: case SqlStatementType.DropTable: case SqlStatementType.DropTrigger: case SqlStatementType.DropView: case SqlStatementType.EventInit: case SqlStatementType.EventWait: case SqlStatementType.Execute: case SqlStatementType.ExecuteImmediate: case SqlStatementType.ExecuteProcedure: this.ProvideCommand().CommandText = sqlStatement; // raise the event this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(this.sqlCommand, autoCommit); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.Fetch: break; case SqlStatementType.Grant: case SqlStatementType.Insert: case SqlStatementType.InsertCursor: case SqlStatementType.Open: case SqlStatementType.Prepare: case SqlStatementType.Revoke: // raise the event this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(this.sqlCommand, autoCommit); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.RecreateProcedure: case SqlStatementType.RecreateTable: case SqlStatementType.RecreateTrigger: case SqlStatementType.RecreateView: // raise the event this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(this.sqlCommand, autoCommit); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.Rollback: // raise the event this.OnCommandExecuting(null); this.sqlTransaction.Rollback(); this.sqlTransaction = null; // raise the event this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.Select: this.ProvideCommand().CommandText = sqlStatement; // raise the event this.OnCommandExecuting(this.sqlCommand); dataReader = this.sqlCommand.ExecuteReader(); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, dataReader, -1); if (!dataReader.IsClosed) { dataReader.Close(); } break; case SqlStatementType.SetGenerator: case SqlStatementType.AlterSequence: // raise the event this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(this.sqlCommand, autoCommit); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.SetDatabase: case SqlStatementType.SetNames: case SqlStatementType.SetSQLDialect: case SqlStatementType.SetStatistics: case SqlStatementType.SetTransaction: case SqlStatementType.ShowSQLDialect: throw new NotImplementedException(); case SqlStatementType.Update: case SqlStatementType.Whenever: // raise the event this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(this.sqlCommand, autoCommit); this.requiresNewConnection = false; // raise the event this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; } } catch (Exception ex) { if (this.sqlTransaction != null) { this.sqlTransaction.Rollback(); this.sqlTransaction = null; } throw new FbException(string.Format(CultureInfo.CurrentUICulture, "An exception was thrown when executing command: {0}{2}Batch execution aborted{2}The returned message was: {1}", sqlStatement, ex.Message, Environment.NewLine)); } } if (this.sqlTransaction != null) { // commit root transaction this.sqlTransaction.Commit(); this.sqlTransaction = null; } this.sqlConnection.Close(); }
public void GlobalCleanup() { FbConnection.ClearAllPools(); FbConnection.DropDatabase(ConnectionString); }
/// <summary> /// Starts the ordered execution of the SQL statements that are in <see cref="SqlStatements"/> collection. /// </summary> /// <param name="autoCommit">Specifies if the transaction should be committed after a DDL command execution</param> public void Execute(bool autoCommit = true) { if ((_statements?.Count ?? 0) == 0) { throw new InvalidOperationException("There are no commands for execution."); } _shouldClose = false; foreach (var statement in Statements) { if (!(statement.StatementType == SqlStatementType.Connect || statement.StatementType == SqlStatementType.CreateDatabase || statement.StatementType == SqlStatementType.Disconnect || statement.StatementType == SqlStatementType.DropDatabase || statement.StatementType == SqlStatementType.SetAutoDDL || statement.StatementType == SqlStatementType.SetDatabase || statement.StatementType == SqlStatementType.SetNames || statement.StatementType == SqlStatementType.SetSQLDialect)) { ProvideCommand(); _sqlCommand.CommandText = statement.Text; if (_sqlTransaction == null && !(statement.StatementType == SqlStatementType.Commit || statement.StatementType == SqlStatementType.Rollback)) { _sqlTransaction = _sqlConnection.BeginTransaction(); } _sqlCommand.Transaction = _sqlTransaction; } try { switch (statement.StatementType) { case SqlStatementType.AlterCharacterSet: case SqlStatementType.AlterDatabase: case SqlStatementType.AlterDomain: case SqlStatementType.AlterException: case SqlStatementType.AlterFunction: case SqlStatementType.AlterIndex: case SqlStatementType.AlterPackage: case SqlStatementType.AlterProcedure: case SqlStatementType.AlterRole: case SqlStatementType.AlterSequence: case SqlStatementType.AlterTable: case SqlStatementType.AlterTrigger: case SqlStatementType.AlterView: case SqlStatementType.CommentOn: case SqlStatementType.CreateCollation: case SqlStatementType.CreateDomain: case SqlStatementType.CreateException: case SqlStatementType.CreateFunction: case SqlStatementType.CreateGenerator: case SqlStatementType.CreateIndex: case SqlStatementType.CreatePackage: case SqlStatementType.CreatePackageBody: case SqlStatementType.CreateProcedure: case SqlStatementType.CreateRole: case SqlStatementType.CreateSequence: case SqlStatementType.CreateShadow: case SqlStatementType.CreateTable: case SqlStatementType.CreateTrigger: case SqlStatementType.CreateView: case SqlStatementType.DeclareCursor: case SqlStatementType.DeclareExternalFunction: case SqlStatementType.DeclareFilter: case SqlStatementType.DeclareStatement: case SqlStatementType.DeclareTable: case SqlStatementType.Delete: case SqlStatementType.DropCollation: case SqlStatementType.DropDomain: case SqlStatementType.DropException: case SqlStatementType.DropExternalFunction: case SqlStatementType.DropFunction: case SqlStatementType.DropFilter: case SqlStatementType.DropGenerator: case SqlStatementType.DropIndex: case SqlStatementType.DropPackage: case SqlStatementType.DropPackageBody: case SqlStatementType.DropProcedure: case SqlStatementType.DropSequence: case SqlStatementType.DropRole: case SqlStatementType.DropShadow: case SqlStatementType.DropTable: case SqlStatementType.DropTrigger: case SqlStatementType.DropView: case SqlStatementType.EventInit: case SqlStatementType.EventWait: case SqlStatementType.Execute: case SqlStatementType.ExecuteImmediate: case SqlStatementType.ExecuteProcedure: case SqlStatementType.Grant: case SqlStatementType.Insert: case SqlStatementType.InsertCursor: case SqlStatementType.Merge: case SqlStatementType.Open: case SqlStatementType.Prepare: case SqlStatementType.Revoke: case SqlStatementType.RecreateFunction: case SqlStatementType.RecreatePackage: case SqlStatementType.RecreatePackageBody: case SqlStatementType.RecreateProcedure: case SqlStatementType.RecreateTable: case SqlStatementType.RecreateTrigger: case SqlStatementType.RecreateView: case SqlStatementType.SetGenerator: case SqlStatementType.Update: case SqlStatementType.Whenever: OnCommandExecuting(_sqlCommand, statement.StatementType); var rowsAffected = ExecuteCommand(autoCommit); _requiresNewConnection = false; OnCommandExecuted(null, statement.Text, statement.StatementType, rowsAffected); break; case SqlStatementType.ExecuteBlock: case SqlStatementType.Select: #warning Who's disposing this? ProvideCommand().CommandText = statement.Text; OnCommandExecuting(_sqlCommand, statement.StatementType); using (var dataReader = _sqlCommand.ExecuteReader()) { _requiresNewConnection = false; OnCommandExecuted(dataReader, statement.Text, statement.StatementType, -1); } break; case SqlStatementType.Commit: OnCommandExecuting(null, statement.StatementType); CommitTransaction(); OnCommandExecuted(null, statement.Text, statement.StatementType, -1); break; case SqlStatementType.Rollback: OnCommandExecuting(null, statement.StatementType); RollbackTransaction(); OnCommandExecuted(null, statement.Text, statement.StatementType, -1); break; case SqlStatementType.CreateDatabase: OnCommandExecuting(null, statement.StatementType); CreateDatabase(statement.CleanText); _requiresNewConnection = false; OnCommandExecuted(null, statement.Text, statement.StatementType, -1); break; case SqlStatementType.DropDatabase: OnCommandExecuting(null, statement.StatementType); FbConnection.DropDatabase(_connectionString.ToString()); _requiresNewConnection = true; OnCommandExecuted(null, statement.Text, statement.StatementType, -1); break; case SqlStatementType.Connect: OnCommandExecuting(null, statement.StatementType); ConnectToDatabase(statement.CleanText); _requiresNewConnection = false; OnCommandExecuted(null, statement.Text, statement.StatementType, -1); break; case SqlStatementType.Disconnect: OnCommandExecuting(null, statement.StatementType); _sqlConnection.Close(); FbConnection.ClearPool(_sqlConnection); _requiresNewConnection = false; OnCommandExecuted(null, statement.Text, statement.StatementType, -1); break; case SqlStatementType.SetAutoDDL: OnCommandExecuting(null, statement.StatementType); SetAutoDdl(statement.CleanText, ref autoCommit); _requiresNewConnection = false; OnCommandExecuted(null, statement.Text, statement.StatementType, -1); break; case SqlStatementType.SetNames: OnCommandExecuting(null, statement.StatementType); SetNames(statement.CleanText); _requiresNewConnection = true; OnCommandExecuted(null, statement.Text, statement.StatementType, -1); break; case SqlStatementType.SetSQLDialect: OnCommandExecuting(null, statement.StatementType); SetSqlDialect(statement.CleanText); _requiresNewConnection = true; OnCommandExecuted(null, statement.Text, statement.StatementType, -1); break; case SqlStatementType.Fetch: case SqlStatementType.Describe: break; case SqlStatementType.SetDatabase: case SqlStatementType.SetStatistics: case SqlStatementType.SetTransaction: case SqlStatementType.ShowSQLDialect: throw new NotImplementedException(); } } catch (Exception ex) { RollbackTransaction(); CloseConnection(); throw new FbException(string.Format("An exception was thrown when executing command: {1}.{0}Batch execution aborted.{0}The returned message was: {2}.", Environment.NewLine, statement.Text, ex.Message), ex); } } CommitTransaction(); CloseConnection(); }
static void Main(string[] args) { Console.WriteLine("Starting Against Test DB: " + args[0] + " " + args[1] + " " + args[2]); Console.WriteLine("Enter to Start"); Console.ReadLine(); FbConnectionStringBuilder csb = new FbConnectionStringBuilder(); csb.DataSource = "localhost"; csb.Port = 3050; csb.UserID = args[1]; csb.Password = args[2]; csb.Database = args[0]; csb.ServerType = FbServerType.Default; Console.WriteLine("Dropping Database"); FbConnection.DropDatabase(csb.ToString()); Console.WriteLine("Creating Database"); FbConnection.CreateDatabase(csb.ToString()); FileInfo Schema = new FileInfo("schema.sql"); String DDL = Schema.OpenText().ReadToEnd(); Console.WriteLine("Applying Schema"); CreateDatabaseSchema(DDL, csb.ToString()); try { using (FbConnection db = new FbConnection(csb.ToString())) { db.Open(); List <int> loops = Enumerable.Range(1, 3).ToList(); foreach (int k in loops) { using (FbTransaction t = db.BeginTransaction()) { try { List <int> words = Enumerable.Range(1, 1).ToList(); foreach (int i in words) { MemoDB m = new MemoDB(); m.MEMO = "TEST"; db.Insert(m, t); } if (k == 2) { Console.WriteLine("Simulating a Close"); db.Close(); } else { t.Commit(); var count = db.Query <Int32>("select count(*) from memo").Single(); Console.WriteLine("Records Written: " + count); } } catch (Exception ex) { t.Rollback(); WriteExceptionLog(ex); } } } } } catch (Exception ex) { WriteExceptionLog(ex); } Console.WriteLine("Stopped... Press Enter to Check for Validation."); Console.ReadLine(); try { using (FbConnection db = new FbConnection(csb.ToString())) { db.Open(); Console.WriteLine("Counting"); var count = db.Query <Int32>("select count(*) from memo").Single(); Console.WriteLine("Records Written: " + count); Console.WriteLine("Deleting"); db.Execute("delete from memo"); } } catch (Exception ex) { WriteExceptionLog(ex); } Console.WriteLine("Ending Application."); Console.ReadLine(); }
/// <summary> /// Starts the ordered execution of the SQL statements that are in <see cref="SqlStatements"/> collection. /// </summary> /// <param name="autoCommit">Specifies if the transaction should be committed after a DDL command execution</param> public void Execute(bool autoCommit = true) { if (this.SqlStatements == null || this.SqlStatements.Count == 0) { throw new InvalidOperationException("There are no commands for execution."); } foreach (string sqlStatement in this.SqlStatements) { if (string.IsNullOrEmpty(sqlStatement)) { continue; } // initializate outputs to default int rowsAffected = -1; FbDataReader dataReader = null; SqlStatementType statementType = FbBatchExecution.GetStatementType(sqlStatement); if (!(statementType == SqlStatementType.Connect || statementType == SqlStatementType.CreateDatabase || statementType == SqlStatementType.Disconnect || statementType == SqlStatementType.DropDatabase || statementType == SqlStatementType.SetAutoDDL || statementType == SqlStatementType.SetDatabase || statementType == SqlStatementType.SetNames || statementType == SqlStatementType.SetSQLDialect)) { this.ProvideCommand(); this.sqlCommand.CommandText = sqlStatement; if (this.sqlTransaction == null && !(statementType == SqlStatementType.Commit || statementType == SqlStatementType.Rollback)) { this.sqlTransaction = this.sqlConnection.BeginTransaction(); } this.sqlCommand.Transaction = this.sqlTransaction; } try { switch (statementType) { case SqlStatementType.AlterDatabase: case SqlStatementType.AlterDomain: case SqlStatementType.AlterException: case SqlStatementType.AlterIndex: case SqlStatementType.AlterProcedure: case SqlStatementType.AlterRole: case SqlStatementType.AlterTable: case SqlStatementType.AlterTrigger: case SqlStatementType.AlterView: this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(autoCommit); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.Commit: this.OnCommandExecuting(null); this.CommitTransaction(); this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.Connect: this.OnCommandExecuting(null); this.ConnectToDatabase(sqlStatement); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.CreateDatabase: this.OnCommandExecuting(null); this.CreateDatabase(sqlStatement); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.CommentOn: case SqlStatementType.CreateCollation: case SqlStatementType.CreateDomain: case SqlStatementType.CreateException: case SqlStatementType.CreateGenerator: case SqlStatementType.CreateIndex: case SqlStatementType.CreateProcedure: case SqlStatementType.CreateRole: case SqlStatementType.CreateSequence: case SqlStatementType.CreateShadow: case SqlStatementType.CreateTable: case SqlStatementType.CreateTrigger: case SqlStatementType.CreateView: case SqlStatementType.DeclareCursor: case SqlStatementType.DeclareExternalFunction: case SqlStatementType.DeclareFilter: case SqlStatementType.DeclareStatement: case SqlStatementType.DeclareTable: case SqlStatementType.Delete: this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(autoCommit); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.Describe: break; case SqlStatementType.Disconnect: this.OnCommandExecuting(null); this.sqlConnection.Close(); FbConnection.ClearPool(this.sqlConnection); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.DropDatabase: this.OnCommandExecuting(null); FbConnection.DropDatabase(this.connectionString.ToString()); this.requiresNewConnection = true; this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.DropCollation: case SqlStatementType.DropDomain: case SqlStatementType.DropException: case SqlStatementType.DropExternalFunction: case SqlStatementType.DropFilter: case SqlStatementType.DropGenerator: case SqlStatementType.DropIndex: case SqlStatementType.DropProcedure: case SqlStatementType.DropSequence: case SqlStatementType.DropRole: case SqlStatementType.DropShadow: case SqlStatementType.DropTable: case SqlStatementType.DropTrigger: case SqlStatementType.DropView: case SqlStatementType.EventInit: case SqlStatementType.EventWait: case SqlStatementType.Execute: case SqlStatementType.ExecuteImmediate: case SqlStatementType.ExecuteProcedure: this.ProvideCommand().CommandText = sqlStatement; this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(autoCommit); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.ExecuteBlock: this.ProvideCommand().CommandText = sqlStatement; this.OnCommandExecuting(this.sqlCommand); dataReader = this.sqlCommand.ExecuteReader(); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, dataReader, -1); if (!dataReader.IsClosed) { dataReader.Close(); } break; case SqlStatementType.Fetch: break; case SqlStatementType.Grant: case SqlStatementType.Insert: case SqlStatementType.InsertCursor: case SqlStatementType.Open: case SqlStatementType.Prepare: case SqlStatementType.Revoke: this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(autoCommit); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.RecreateProcedure: case SqlStatementType.RecreateTable: case SqlStatementType.RecreateTrigger: case SqlStatementType.RecreateView: this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(autoCommit); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.Rollback: this.OnCommandExecuting(null); this.RollbackTransaction(); this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.Select: this.ProvideCommand().CommandText = sqlStatement; this.OnCommandExecuting(this.sqlCommand); dataReader = this.sqlCommand.ExecuteReader(); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, dataReader, -1); if (!dataReader.IsClosed) { dataReader.Close(); } break; case SqlStatementType.SetAutoDDL: this.OnCommandExecuting(null); this.SetAutoDdl(sqlStatement, ref autoCommit); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.SetGenerator: case SqlStatementType.AlterSequence: this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(autoCommit); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; case SqlStatementType.SetNames: this.OnCommandExecuting(null); this.SetNames(sqlStatement); this.requiresNewConnection = true; this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.SetSQLDialect: this.OnCommandExecuting(null); this.SetSqlDialect(sqlStatement); this.requiresNewConnection = true; this.OnCommandExecuted(sqlStatement, null, -1); break; case SqlStatementType.SetDatabase: case SqlStatementType.SetStatistics: case SqlStatementType.SetTransaction: case SqlStatementType.ShowSQLDialect: throw new NotImplementedException(); case SqlStatementType.Update: case SqlStatementType.Whenever: this.OnCommandExecuting(this.sqlCommand); rowsAffected = this.ExecuteCommand(autoCommit); this.requiresNewConnection = false; this.OnCommandExecuted(sqlStatement, null, rowsAffected); break; } } catch (Exception ex) { this.RollbackTransaction(); throw new FbException(string.Format("An exception was thrown when executing command: {1}.{0}Batch execution aborted.{0}The returned message was: {2}.", Environment.NewLine, sqlStatement, ex.Message)); } } this.CommitTransaction(); this.sqlConnection.Close(); }
public static void DropDatabase(TargetVersion version, DatabaseLocation location) { FbConnection.DropDatabase(GetConnectionString(version, location)); }
private static void DropDatabase(string connectionString) { FbConnection.DropDatabase(connectionString); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public override void Delete() { ClearAllPools(); FbConnection.DropDatabase(_connection.ConnectionString); }
public void DropDatabase(string fileName) { string dbConn = string.Format(@"ServerType=1;Database={0}", fileName); FbConnection.DropDatabase(dbConn); }
public override void Delete() { FbConnection.ClearPool((FbConnection)_connection.DbConnection); FbConnection.DropDatabase(_connection.ConnectionString); }