Acme.Northwind.Install.SqlServers.DeleteExtendedProperty C# (CSharp) Method

DeleteExtendedProperty() static private method

static private DeleteExtendedProperty ( string connectionString, string propertyName ) : void
connectionString string
propertyName string
return void
		internal static void DeleteExtendedProperty(string connectionString, string propertyName)
		{
			//If the database supports extended properties then use them no matter what
			if (CanUseExtendedProperty(connectionString) && ExtendedPropertyExists(connectionString, propertyName, string.Empty, string.Empty, string.Empty))
			{
				System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
				try
				{
					conn.ConnectionString = connectionString;
					conn.Open();
					SqlCommand cmdGetExtProp = new SqlCommand();
					cmdGetExtProp.CommandText = String.Format("EXEC sp_dropextendedproperty '{0}'", new object[] { propertyName });
					cmdGetExtProp.CommandType = System.Data.CommandType.Text;
					cmdGetExtProp.Connection = conn;
					cmdGetExtProp.ExecuteNonQuery();
				}
				catch (Exception ex)
				{
					throw ex;
				}
				finally
				{
					if (conn != null)
						conn.Close();
				}
			}
		}