public void ExecuteParameterizedQuery(
string connectionString,
String[] firstNameArray,
String[] lastNameArray)
{
//Open a session to Teradata.
TdConnection cn = new TdConnection(connectionString);
try
{
cn.Open();
// Initialize a command.
TdCommand cmd = new TdCommand(
"Insert into Customers (FirstName, LastName) values (?, ?)",
cn);
// Set the first name parameter.
TdParameter firstName = cmd.CreateParameter();
firstName.DbType = DbType.String;
firstName.Direction = ParameterDirection.Input;
cmd.Parameters.Add(firstName);
// Set the last name parameter.
TdParameter lastName = cmd.CreateParameter();
lastName.DbType = DbType.String;
lastName.Direction = ParameterDirection.Input;
cmd.Parameters.Add(lastName);
// Prepare the query.
cmd.Prepare();
for (Int32 index = 0; (index < firstNameArray.Length) &&
(index < lastNameArray.Length); index++)
{
// Initialize the parameter values.
firstName.Value = firstNameArray[index];
lastName.Value = lastNameArray[index];
// Execute the command.
cmd.ExecuteNonQuery();
}
cmd.Dispose()
}
finally
{
cn.Close();
}