Send feedback on this topic.
Teradata.Client.Provider
Parameters Property
Example 



Teradata.Client.Provider Namespace > TdCommand Class : Parameters Property
Gets the TdParameterCollection object.
Syntax
'Declaration
 
Public Shadows ReadOnly Property Parameters As TdParameterCollection
'Usage
 
Dim instance As TdCommand
Dim value As TdParameterCollection
 
value = instance.Parameters
public new TdParameterCollection Parameters {get;}
public:
new property TdParameterCollection^ Parameters {
   TdParameterCollection^ get();
}
Exceptions
ExceptionDescription
The TdCommand is closed / disposed.
Remarks

The .NET Data Provider does not support named parameters. TdParameterCollection dictates the sequence of the data (parameters) passed to the Advanced SQL Engine. The first element of the collection is written to the Data stream followed by the second parameter and so forth.

The .NET Data Provider does not support SQL statements with USING Row Descriptor. The SQL Statement must use parameter markers (For example: Select * from Customers where CustomerID = ?).

Example
The following example creates a TdConnection object and a TdCommand object. The example creates the last name and first name parameters, then prepares the command and executes the insert command repeatedly.
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();
    }
Requirements

Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019

See Also

Reference

TdCommand Class
TdCommand Members