Acme.PROJECTNAME.Install.SqlServers.InsertExtendedPropery C# (CSharp) Метод

InsertExtendedPropery() приватный статический Метод

private static InsertExtendedPropery ( string connectionString, string property, string propertyValue, string user, string table, string column ) : void
connectionString string
property string
propertyValue string
user string
table string
column string
Результат void
		private static void InsertExtendedPropery(string connectionString, string property, string propertyValue, string user, string table, string column)
		{
			string userName = string.Empty;
			string userValue = string.Empty;
			string tableName = string.Empty;
			string tableValue = string.Empty;
			string columnName = string.Empty;
			string columnValue = string.Empty;

			property = "'" + property + "'";
			propertyValue = "'" + propertyValue + "'";
			if(user == string.Empty)
			{
				userName = "NULL";
				userValue = "NULL";
			}
			else
			{
				userName = "'user'";
				userValue = "'" + user + "'";
			}
			if(table == string.Empty)
			{
				tableName = "NULL";
				tableValue = "NULL";
			}
			else
			{
				tableName = "'table'";
				tableValue = "'" + table + "'";
			}
			if(column == string.Empty)
			{
				columnName = "NULL";
				columnValue = "NULL";
			}
			else
			{
				columnName = "'column'";
				columnValue = "'" + column + "'";
			}

			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_addextendedproperty {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", new object[]{property, propertyValue, userName, userValue, tableName, tableValue, columnName, columnValue});
				cmdGetExtProp.CommandType = System.Data.CommandType.Text;
				cmdGetExtProp.Connection = conn;
				cmdGetExtProp.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				throw ex;
			}
			finally
			{
				if(conn != null)
					conn.Close();
			}
		}