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

Clone() public method

Creates a new MySqlConnection object with the exact same ConnectionString value
public Clone ( ) : MySqlConnection
return MySqlConnection
        public MySqlConnection Clone()
        {
            MySqlConnection clone = new MySqlConnection();
            string connectionString = settings.ConnectionString;
            if (connectionString != null)
                clone.ConnectionString = connectionString;
            return clone;
        }

Usage Example

Exemplo n.º 1
0
        public Fruits Create(Fruits t)
        {
            MySqlConnection conn = DB.DBUtils.GetDBConnection();

            conn.OpenAsync();
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText =
                    "INSERT INTO warehouse.fruit(FruitType,DealerCountry,Price,Count) VALUES(?FruitType,?DealerCountry,?Price,?Count)";
                cmd.Connection = conn;
                cmd.Parameters.Add("?Price", MySqlDbType.VarChar).Value         = t.Price;
                cmd.Parameters.Add("?Count", MySqlDbType.VarChar).Value         = t.Count;
                cmd.Parameters.Add("?FruitType", MySqlDbType.VarChar).Value     = t.Type;
                cmd.Parameters.Add("?DealerCountry", MySqlDbType.VarChar).Value = t.Country;
                cmd.ExecuteNonQueryAsync();
                conn.Clone();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(t);
        }
All Usage Examples Of MySql.Data.MySqlClient.MySqlConnection::Clone