Or another question: Is it possible to execute "Create table" statement in transaction and later rollback this transaction to undelete table?
I'm asking because event if I write code with AutoCommit set to False,: FbConnection c = new FbConnection(@"Database=employee.fdb;User=SYSDBA;Password=masterkey"); c.Open(); try { FbBatchExecution fbe = new FbBatchExecution(c); foreach (string cmd in script.Results) { fbe.SqlStatements.Add(cmd); } fbe.Execute(false); } catch(Exception) { throw; } c.Close(); after executing and getting error with 24th line of my script the transaction should rollback. But operations from 1 to 23 line from script are still in database. In my script there are "Create table" and "Insert" statement . Chris -------------------------------------------------- From: "Krzysztof Jeske" <wpiszlo...@wp.pl> Sent: Wednesday, March 10, 2010 1:55 PM To: <firebird-net-provider@lists.sourceforge.net> Subject: Batch execution with transaction > Hi, > > I have in sql script 30 lines of SQL code. When I execute this script and > I got an error on 24th line I have to rollback previous changes (23 > lines). So I write code: > > FbConnection c = new > FbConnection(@"Database=employee.fdb;User=SYSDBA;Password=masterkey"); > c.Open(); > > using (FbTransaction tr = c.BeginTransaction()) > { > try > { > FbBatchExecution fbe = new FbBatchExecution(c); > foreach (string cmd in script.Results) > { > fbe.SqlStatements.Add(cmd); > } > > fbe.Execute(false); > tr.Commit(); > } > catch(Exception) > { > tr.Rollback(); > throw; > } > } > > c.Close(); > > After executing I get an error: > Batch execution aborted. The returned message was: Execute requires the > Command object to have a Transaction object when > the Connection object assigned to the comm... > > So, what I have to do to make my code working? > > Regards, > Chris ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider