public GetRealOpenConnection ( IBM.Data.DB2.DB2Connection connection ) : |
||
connection | IBM.Data.DB2.DB2Connection | |
Результат |
unsafe public void Open() { if (disposed) { throw new ObjectDisposedException("DB2Connection"); } if (this.State == ConnectionState.Open || this.State == ConnectionState.Connecting || this.State == ConnectionState.Executing || this.State == ConnectionState.Fetching) { throw new InvalidOperationException("Connection already open"); } try { openConnection = connectionSettings.GetRealOpenConnection(this); } catch (DB2Exception) { Close(); throw; } }
//private void InternalOpen() //{ // try // { // DB2Constants.RetCode sqlRet = (DB2Constants.RetCode)DB2CLIWrapper.SQLAllocHandle(DB2Constants.SQL_HANDLE_DBC, DB2Environment.Instance.PenvHandle, out dbHandle); // DB2ClientUtils.DB2CheckReturn(sqlRet, DB2Constants.SQL_HANDLE_DBC, DB2Environment.Instance.PenvHandle, "Unable to allocate database handle in DB2Connection.", this); // StringBuilder outConnectStr = new StringBuilder(DB2Constants.SQL_MAX_OPTION_STRING_LENGTH); // short numOutCharsReturned; // sqlRet = (DB2Constants.RetCode)DB2CLIWrapper.SQLDriverConnect(dbHandle, IntPtr.Zero, // connectionString, DB2Constants.SQL_NTS, // outConnectStr, DB2Constants.SQL_MAX_OPTION_STRING_LENGTH, out numOutCharsReturned, // DB2Constants.SQL_DRIVER_NOPROMPT); // DB2ClientUtils.DB2CheckReturn(sqlRet, DB2Constants.SQL_HANDLE_DBC, dbHandle, "Unable to connect to the database.", this); // databaseProductName = SQLGetInfo(dbHandle, DB2Constants.SQL_DBMS_NAME); // databaseVersion = SQLGetInfo(dbHandle, DB2Constants.SQL_DBMS_VER); // /* Set the attribute SQL_ATTR_XML_DECLARATION to skip the XML declaration from XML Data */ // sqlRet = (DB2Constants.RetCode)DB2CLIWrapper.SQLSetConnectAttr(dbHandle, DB2Constants.SQL_ATTR_XML_DECLARATION, new IntPtr(DB2Constants.SQL_XML_DECLARATION_NONE), DB2Constants.SQL_NTS); // DB2ClientUtils.DB2CheckReturn(sqlRet, DB2Constants.SQL_HANDLE_DBC, dbHandle, "Unable to set SQL_ATTR_XML_DECLARATION", this); // nativeOpenPerformed = true; // } // catch // { // if (dbHandle != IntPtr.Zero) // { // DB2CLIWrapper.SQLFreeHandle(DB2Constants.SQL_HANDLE_DBC, dbHandle); // dbHandle = IntPtr.Zero; // } // throw; // } //} public override void Open() { if (disposed) { throw new ObjectDisposedException("DB2Connection"); } if (this.State == ConnectionState.Open) { throw new InvalidOperationException("Connection already open"); } try { //InternalOpen(); openConnection = connectionSettings.GetRealOpenConnection(this); } catch (DB2Exception) { Close(); throw; } }