MySql.Data.MySqlClient.MySqlConnection.Close C# (CSharp) Method

Close() public method

public Close ( ) : void
return void
        public override void Close()
        {
            if (State == ConnectionState.Closed) return;

            if (Reader != null)
                Reader.Close();

			// if the reader was opened with CloseConnection then driver
			// will be null on the second time through
			if (driver != null)
			{
#if !CF
				if (driver.CurrentTransaction == null)
#endif	
			        CloseFully();
#if !CF
				else
					driver.IsInActiveUse = false;
#endif
			}

            SetState(ConnectionState.Closed, true);
        }

Usage Example

Exemplo n.º 1
0
        public void EditSpecification(Specification s)
        {
            using (connect = new MySqlConnection(_connectionString))
            {
                connect.Open();
                using (MySqlTransaction transaction = connect.BeginTransaction())
                {

                    try
                    {
                        string query = "EditPackageSpecification";
                        var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure };

                        cmd.Parameters.AddWithValue("SpecificationID", s.ID);
                        cmd.Parameters.AddWithValue("PWeight", s.Weight);
                        cmd.Parameters.AddWithValue("DeimensionHeight", s.Height);
                        cmd.Parameters.AddWithValue("DimensionWidth", s.Width);
                        cmd.Parameters.AddWithValue("DimensionLength", s.Length);

                        cmd.ExecuteNonQuery();

                        connect.Close();
                    }
                    catch (InvalidOperationException ioException)
                    {
                        connect.Close();
                    }
                }
            }
        }
All Usage Examples Of MySql.Data.MySqlClient.MySqlConnection::Close