Update of /cvsroot/pgsqlclient/pgsqlclient/PostgreSql.Data.PGSqlClient/source
In directory sc8-pr-cvs1:/tmp/cvs-serv4429
Modified Files:
PGConnection.cs
Log Message:
Added implementation for ChangeDatabase.
Index: PGConnection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient/PostgreSql.Data.PGSqlClient/source/PGConnection.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PGConnection.cs 16 Jul 2003 19:33:21 -0000 1.3
--- PGConnection.cs 29 Jul 2003 23:26:12 -0000 1.4
***************
*** 311,315 ****
public void ChangeDatabase(string db)
{
! /* TODO: Implementation */
}
--- 311,347 ----
public void ChangeDatabase(string db)
{
! if (state == ConnectionState.Closed)
! {
! throw new InvalidOperationException("ChangeDatabase requires an open and available Connection.");
! }
!
! if (db == null || db.Trim().Length == 0)
! {
! throw new InvalidOperationException("Database name is not valid.");
! }
!
! if (this.DataReader != null)
! {
! throw new InvalidOperationException("ChangeDatabase requires an open and available Connection. The connection's current state is Open, Fetching.");
! }
!
! string oldDb = this.dbConnection.Settings.Database;
!
! try
! {
! /* Close current connection */
! this.Close();
!
! /* Set up the new Database */
! this.dbConnection.Settings.Database = db;
!
! /* Open new connection to new database */
! this.Open();
! }
! catch (PGException ex)
! {
! this.dbConnection.Settings.Database = oldDb;
! throw ex;
! }
}
|