Esempio n. 1
0
        public override void BeginTransaction(CLI.IsolationLevel level)
        {
            CLI.ReturnCode rc = (CLI.ReturnCode)CLI.SQLSetConnectAttr(
                hdbc,
                (int)CLI.ConnectionAttribute.SQL_ATTR_AUTOCOMMIT,
                (IntPtr)(int)CLI.AutoCommit.SQL_AUTOCOMMIT_OFF,
                (int)CLI.LengthCode.SQL_IS_UINTEGER);
            if (rc != CLI.ReturnCode.SQL_SUCCESS)
            {
                HandleConnectionErrors(rc);
            }
            rc = (CLI.ReturnCode)CLI.SQLSetConnectAttr(
                hdbc,
                (int)CLI.ConnectionAttribute.SQL_ATTR_TXN_ISOLATION,
                (IntPtr)(int)level,
                (int)CLI.LengthCode.SQL_IS_UINTEGER);
            if (rc != CLI.ReturnCode.SQL_SUCCESS)
            {
                if (rc == CLI.ReturnCode.SQL_SUCCESS_WITH_INFO)
                {
                    Diagnostics.HandleWarnings(this, OuterConnection);
                }
                else
                {
                    try
                    {
                        Diagnostics.HandleErrors(rc, CLI.HandleType.SQL_HANDLE_DBC, hdbc);
                    }
                    finally
                    {
                        CLI.SQLSetConnectAttr(
                            hdbc,
                            (int)CLI.ConnectionAttribute.SQL_ATTR_AUTOCOMMIT,
                            (IntPtr)(int)CLI.AutoCommit.SQL_AUTOCOMMIT_ON,
                            (int)CLI.LengthCode.SQL_IS_UINTEGER);
                    }
                }
            }

            GC.KeepAlive(this);
        }
Esempio n. 2
0
        public override void EndTransaction(bool commit)
        {
            Debug.WriteLineIf(CLI.FnTrace.Enabled, String.Format(
                                  "ManagedConnection.EndTransaction ({0})", commit));
            CLI.CompletionType completion = commit ?
                                            CLI.CompletionType.SQL_COMMIT :
                                            CLI.CompletionType.SQL_ROLLBACK;
            Future future = new Future(
                Service.Transaction, (int)completion, null);
            object result = null;

            try
            {
                futures.Add(future);
                future.SendRequest(Session);
                result = future.GetNextResult(Session, futures);
                Debug.WriteLineIf(CLI.FnTrace.Enabled, String.Format(
                                      "ManagedConnection.EndTransaction ({0}) success", commit));
            }
            finally
            {
                futures.Remove(future);
            }
            if (result is object[])
            {
                Debug.WriteLineIf(CLI.FnTrace.Enabled, String.Format(
                                      "ManagedConnection.EndTransaction ({0}) error", commit));
                object[] results = (object[])result;
                errors.AddServerError((string)results[1], null, (string)results[2]);
                Diagnostics.HandleErrors(CLI.ReturnCode.SQL_ERROR, this);
            }

            autocommit = true;
            isolation  = CLI.IsolationLevel.SQL_TXN_READ_COMMITED;
            Debug.WriteLineIf(CLI.FnTrace.Enabled, String.Format(
                                  "ManagedConnection.EndTransaction ({0}) done", commit));
        }
Esempio n. 3
0
 public override void BeginTransaction(CLI.IsolationLevel level)
 {
     autocommit = false;
     isolation  = level;
 }
Esempio n. 4
0
 public abstract void BeginTransaction(CLI.IsolationLevel level);
		public override void EndTransaction (bool commit)
		{
		        Debug.WriteLineIf (CLI.FnTrace.Enabled, String.Format (
			      "ManagedConnection.EndTransaction ({0})", commit));
			  CLI.CompletionType completion = commit ? 
			      CLI.CompletionType.SQL_COMMIT : 
			      CLI.CompletionType.SQL_ROLLBACK;
			  Future future = new Future (
			      Service.Transaction, (int) completion, null);
			  object result = null;
			  try 
			  {
			 	  futures.Add (future);
				  future.SendRequest (Session);
				  result = future.GetNextResult (Session, futures);
				  Debug.WriteLineIf (CLI.FnTrace.Enabled, String.Format (
				      "ManagedConnection.EndTransaction ({0}) success", commit));
			  }
			  finally
			  {
				  futures.Remove (future);
			  }
			  if (result is object[])
			  {
			    Debug.WriteLineIf (CLI.FnTrace.Enabled, String.Format (
				"ManagedConnection.EndTransaction ({0}) error", commit));
				  object[] results = (object[]) result;
				  errors.AddServerError ((string) results[1], null, (string) results[2]);
				  Diagnostics.HandleErrors (CLI.ReturnCode.SQL_ERROR, this);
			  }

			autocommit = true;
			isolation = CLI.IsolationLevel.SQL_TXN_READ_COMMITED;
		        Debug.WriteLineIf (CLI.FnTrace.Enabled, String.Format (
			      "ManagedConnection.EndTransaction ({0}) done", commit));
		}
		public override void BeginTransaction (CLI.IsolationLevel level)
		{
			autocommit = false;
			isolation = level;
		}