public static void DeleteBrand(BrandItem item) { using (SqlConnection connection = new SqlConnection(GetConecctionString().ConnectionString)) { connection.Open(); String sql = @"delete dbo.OurBrands where Brand =@name"; using (SqlCommand command = new SqlCommand(sql, connection)) { command.Parameters.Add("name", System.Data.SqlDbType.NVarChar).Value = item.Name; command.ExecuteNonQuery(); } } }
public static void AddBrand(BrandItem itemToAdd) { using (SqlConnection connection = new SqlConnection(GetConecctionString().ConnectionString)) { connection.Open(); String sql = @"insert dbo.OurBrands(Brand, Country) values(@name , @country);"; using (SqlCommand command = new SqlCommand(sql, connection)) { command.Parameters.Add("name", System.Data.SqlDbType.NVarChar).Value = itemToAdd.Name; command.Parameters.Add("country", System.Data.SqlDbType.NVarChar).Value = itemToAdd.Country; command.ExecuteNonQuery(); } } }