[pgsqlclient-checkins] SF.net SVN: pgsqlclient: [44] trunk/pgsqlclient/source/PostgreSql/Data/Postgr
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2006-03-22 12:09:24
|
Revision: 44 Author: carlosga_fb Date: 2006-03-22 04:09:12 -0800 (Wed, 22 Mar 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=44&view=rev Log Message: ----------- Bug fixes Modified Paths: -------------- trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgConnection.cs trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgDataReader.cs Modified: trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgConnection.cs =================================================================== --- trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgConnection.cs 2006-03-22 12:08:42 UTC (rev 43) +++ trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgConnection.cs 2006-03-22 12:09:12 UTC (rev 44) @@ -305,6 +305,10 @@ public override void Open() { + if (this.connectionString == null || this.connectionString.Length == 0) + { + throw new InvalidOperationException("Connection String is not initialized."); + } if (this.state != ConnectionState.Closed) { throw new InvalidOperationException("Connection already Open."); @@ -356,52 +360,54 @@ { if (this.state == ConnectionState.Open) { - try - { - lock (this.connectionInternal) - { + try + { + lock (this.connectionInternal) + { PgDatabase database = this.connectionInternal.Database; - // Remove info message callback - this.connectionInternal.Database.InfoMessage = null; + // Remove info message callback + this.connectionInternal.Database.InfoMessage = null; - // Remove notification callback - this.connectionInternal.Database.Notification = null; + // Remove notification callback + this.connectionInternal.Database.Notification = null; // Remove SSL callback handlers - this.connectionInternal.Database.UserCertificateValidationCallback = null; - this.connectionInternal.Database.UserCertificateSelectionCallback = null; + this.connectionInternal.Database.UserCertificateValidationCallback = null; + this.connectionInternal.Database.UserCertificateSelectionCallback = null; - // Dispose Active commands - this.connectionInternal.ClosePreparedCommands(); + // Dispose Active commands + this.connectionInternal.ClosePreparedCommands(); - // Rollback active transaction - this.connectionInternal.DisposeActiveTransaction(); + // Rollback active transaction + this.connectionInternal.DisposeActiveTransaction(); - // Close connection permanently or send it back to the pool - if (this.connectionInternal.Pooled) - { - PgConnectionPool.FreeConnection(this.connectionInternal); - } - else - { - this.connectionInternal.Disconnect(); - } - } + // Close connection permanently or send it back to the pool + if (this.connectionInternal.Pooled) + { + PgConnectionPool.FreeConnection(this.connectionInternal); + } + else + { + this.connectionInternal.Disconnect(); + } + } + } + catch + { + } + finally + { - // Update state - this.state = ConnectionState.Closed; + // Update state + this.state = ConnectionState.Closed; - // Raise StateChange event - if (this.StateChange != null) - { - this.StateChange(this, new StateChangeEventArgs(ConnectionState.Open, this.state)); - } - } - catch (PgClientException ex) - { - throw new PgException(ex.Message, ex); - } + // Raise StateChange event + if (this.StateChange != null) + { + this.StateChange(this, new StateChangeEventArgs(ConnectionState.Open, this.state)); + } + } } } Modified: trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgDataReader.cs =================================================================== --- trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgDataReader.cs 2006-03-22 12:08:42 UTC (rev 43) +++ trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgDataReader.cs 2006-03-22 12:09:12 UTC (rev 44) @@ -221,12 +221,10 @@ PgCommand columnsCmd = new PgCommand(this.GetColumnsSql(), this.connection); columnsCmd.Parameters.Add("@OidNumber", PgDbType.Int4); columnsCmd.Parameters.Add("@OidTable", PgDbType.Int4); - columnsCmd.InternalPrepare(); - + PgCommand primaryKeyCmd = new PgCommand(this.GetPrimaryKeysSql(), this.connection); primaryKeyCmd.Parameters.Add("@OidTable", PgDbType.Int4); - primaryKeyCmd.InternalPrepare(); - + for (int i = 0; i < command.Statement.RowDescriptor.Fields.Length; i++) { object[] columnInfo = null; @@ -238,7 +236,10 @@ primaryKeyCmd.Parameters[0].Value = command.Statement.RowDescriptor.Fields[i].OidTable; - columnsCmd.InternalExecute(); + columnsCmd.InternalPrepare(); // First time it will prepare the command, next times it will close the open portal + columnsCmd.InternalExecute(); + + primaryKeyCmd.InternalPrepare(); // First time it will prepare the command, next times it will close the open portal primaryKeyCmd.InternalExecute(); // Get Column Information This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |