Exemplo n.º 1
0
 /// <summary>
 /// Main Constructor - will instance a new MySqlConnection without Open.
 /// </summary>
 /// <param name="Server"></param>
 /// <param name="User"></param>
 /// <param name="Password"></param>
 /// <param name="Database"></param>
 public MySqlWrapper(string Server, int Port, string User, string Password, string Database)
 {
     mServer   = Server;
     mPort     = Port;
     mUser     = User;
     mPassword = Password;
     mDatabase = Database;
     mState    = MysqlState.Closed;
 }
Exemplo n.º 2
0
        /// <summary>
        /// internal method to Close an instanced Connection
        /// </summary>
        /// <param name="FreeConnection"></param>
        /// <returns></returns>
        public MysqlError Close(bool FreeConnection)
        {
            mLastError = null;

            if (mConnection == null)
            {
                mState = MysqlState.Error;
                return(MysqlError.CloseBeforeInit);
            }

            try {
                mConnection.Close();

                if (mConnection.State != System.Data.ConnectionState.Closed)
                {
                    mState = MysqlState.Error;
                    return(MysqlError.FailedToClose);
                }
            } catch (MySqlException e) {
                mState     = MysqlState.Error;
                mLastError = e;
                return(MysqlError.CanNotDisconnectFromDB);
            } catch (Exception e) {
                mState     = MysqlState.Error;
                mLastError = e;
                return(MysqlError.UnknownClose);
            } finally {
                // free Memory
                if (mCommand != null)
                {
                    mCommand.Dispose();
                }
                if (mAdapter != null)
                {
                    mAdapter.Dispose();
                }
                if (FreeConnection == true && mConnection != null)
                {
                    mConnection.Dispose();
                }
            }

            mState = MysqlState.Closed;
            return(MysqlError.None);
        }
Exemplo n.º 3
0
        /// <summary>
        /// method to Open an instanced Connection
        /// </summary>
        /// <returns></returns>
        public MysqlError Open()
        {
            mLastError = null;

            if (mConnection == null)
            {
                return(MysqlError.OpenBeforeInit);
            }

            // no need to open if allready done
            if (mConnection.State == System.Data.ConnectionState.Open)
            {
                mState = MysqlState.Open;
                return(MysqlError.None);
            }

            try {
                mConnection.Open();

                if (mConnection.State != System.Data.ConnectionState.Open)
                {
                    mState = MysqlState.Error;
                    return(MysqlError.FailedToOpen);
                }
            } catch (MySqlException e) {
                mState     = MysqlState.Error;
                mLastError = e;
                return(MysqlError.CanNotConnectToDB);
            } catch (Exception e) {
                mState     = MysqlState.Error;
                mLastError = e;
                return(MysqlError.UnknownOpen);
            }

            mState = MysqlState.Open;
            return(MysqlError.None);
        }
Exemplo n.º 4
0
		/// <summary>
		/// internal method to Close an instanced Connection
		/// </summary>
		/// <param name="FreeConnection"></param>
		/// <returns></returns>
		public MysqlError Close( bool FreeConnection ) {
			mLastError = null;

			if( mConnection == null ) {
				mState = MysqlState.Error;
				return MysqlError.CloseBeforeInit;
			}

			try {
				mConnection.Close();

				if( mConnection.State != System.Data.ConnectionState.Closed ) {
					mState = MysqlState.Error;
					return MysqlError.FailedToClose;
				}
			} catch( MySqlException e ) {
				mState = MysqlState.Error;
				mLastError = e;
				return MysqlError.CanNotDisconnectFromDB;
			} catch( Exception e ) {
				mState = MysqlState.Error;
				mLastError = e;
				return MysqlError.UnknownClose;
			} finally {
				// free Memory
				if( mCommand != null )
					mCommand.Dispose();
				if( mAdapter != null )
					mAdapter.Dispose();
				if( FreeConnection == true && mConnection != null )
					mConnection.Dispose();
			}

			mState = MysqlState.Closed;
			return MysqlError.None;
		} 
Exemplo n.º 5
0
		/// <summary>
		/// method to Open an instanced Connection
		/// </summary>
		/// <returns></returns>
		public MysqlError Open() {
			mLastError = null;

			if( mConnection == null )
				return MysqlError.OpenBeforeInit;

			// no need to open if allready done
			if( mConnection.State == System.Data.ConnectionState.Open ) {
				mState = MysqlState.Open;
				return MysqlError.None;
			}

			try {
				mConnection.Open();

				if( mConnection.State != System.Data.ConnectionState.Open ) {
					mState = MysqlState.Error;
					return MysqlError.FailedToOpen;
				}
			} catch( MySqlException e ) {
				mState = MysqlState.Error;
				mLastError = e;
				return MysqlError.CanNotConnectToDB;
			} catch( Exception e ) {
				mState = MysqlState.Error;
				mLastError = e;
				return MysqlError.UnknownOpen;
			}

			mState = MysqlState.Open;
			return MysqlError.None;
		}
Exemplo n.º 6
0
		/// <summary>
		/// Main Constructor - will instance a new MySqlConnection without Open.
		/// </summary>
		public MySqlWrapper() {
			mState = MysqlState.Closed;
		} 
Exemplo n.º 7
0
		/// <summary>
		/// Main Constructor - will instance a new MySqlConnection without Open.
		/// </summary>
		/// <param name="Server"></param>
		/// <param name="User"></param>
		/// <param name="Password"></param>
		/// <param name="Database"></param>
		public MySqlWrapper( string Server, int Port, string User, string Password, string Database ) {
			mServer = Server;
			mPort = Port;
			mUser = User;
			mPassword = Password;
			mDatabase = Database;
			mState = MysqlState.Closed;
		}
Exemplo n.º 8
0
 /// <summary>
 /// Main Constructor - will instance a new MySqlConnection without Open.
 /// </summary>
 public MySqlWrapper()
 {
     mState = MysqlState.Closed;
 }