Assuming your selected party names and exchange types are in some sort of collection, you could use a StringBuilder to build the query string:
StringBuilder query = new StringBuilder("select * from table t where ");
for (int i = 0; i < names.Count; i++)
{
builder.AppendFormat("t.partyname='{0}' ", names[i]);
if (names.Count - 1 == i)
{
builder.Append("AND ");
}
}
if (types.Count > 0)
{
builder.Append("AND ");
}
for (int i = 0; i < types.Count; i++)
{
builder.AppendFormat("t.exchangetype='{0}'", types[i]);
if (types.Count - 1 == i)
{
builder.Append("AND ");
}
}