static public void QueryBandExample()
{
TdConnection conn = new TdConnection(
@"DataSource=teradata1;UserId=user1;Password=password1;QueryBand='ProxyUser=user1;ApplicationName=app1;'");
// The Query Bands specified using the QueryBand connection string attribute
// are defined at the Connection level.
conn.Open();
// Retrieving the Query Bands from the connection
TdQueryBand qb = conn.QueryBand;
// Adding a new Query Band to the connection.
// This is a custom Query Band only used by the application.
qb["CustomBand"] = "custom1";
// After the TdQueryBand instance has been modified it needs to be
// applied by the connection
conn.ChangeQueryBands(qb);
//
// The method performs required tasks
//
// Defining Query Bands that will be used in a transaction
TdQueryBand transQB = new TdQueryBand("Group=group1");
// Overwriting the ApplicationName that was defined at the Connection level
transQB["ApplicationName"] = "newName";
// Starting a transaction
TdTransaction trans = conn.BeginTransaction(transQb);
// Query Bands defined at the Connection level are also valid
// in the transaction.
// Adding additional transaction level Query Bands by using the Add method
//
// After the transaction is started, it is recommended that the Query Bands
// be retrieved from the TdTransaction.QueryBand property if changes are to
// be made.
transQB = trans.QueryBand;
transQB.Add("JobId", "123");
transQB.Add("JobGroup", "appGroup1");
// After changes are made, the Query Band must be applied to the Transaction.
trans.ChangeQueryBand(transQB);
//
// The method performs required tasks
//
// After the transaction is closed, the Query Bands defined at the Transaction
// level no longer exist. The connection level Query Bands are still valid.
// Any Query Bands that were re-defined at the Transaction level are restored
// to their values defined at the Connection level.
trans.Commit();
//
// Method performs required tasks
//
conn.Close();
}