IDbCommand.Parameters IDbCommand.Parameters IDbCommand.Parameters IDbCommand.Parameters Property

정의

IDataParameterCollection를 가져옵니다.Gets the IDataParameterCollection.

public:
 property System::Data::IDataParameterCollection ^ Parameters { System::Data::IDataParameterCollection ^ get(); };
public System.Data.IDataParameterCollection Parameters { get; }
member this.Parameters : System.Data.IDataParameterCollection
Public ReadOnly Property Parameters As IDataParameterCollection

속성 값

SQL 문 또는 저장 프로시저의 매개 변수The parameters of the SQL statement or stored procedure.

예제

다음 예제에서는 파생된 클래스의 인스턴스를 만들고 SqlCommand, 해당 매개 변수를 표시 합니다.The following example creates an instance of the derived class, SqlCommand, and displays its parameters. 예제에서는 애플리케이션 전달를 SqlConnection, 배열 및 TRANSACT-SQL SELECT 문에 쿼리 문자열로 SqlParameter 개체입니다.In the example, the application passes a SqlConnection, a query string that is a Transact-SQL SELECT statement, and an array of SqlParameter objects.

public void CreateSqlCommand(SqlConnection myConnection,
    string queryString, SqlParameter[] paramArray) 
{
    SqlCommand command = new SqlCommand(queryString, myConnection);
    command.CommandText = 
        "SELECT CustomerID, CompanyName FROM Customers " 
        + "WHERE Country = @Country AND City = @City";    
    command.Parameters.AddRange(paramArray);

    string message = "";
    for (int i = 0; i < command.Parameters.Count; i++) 
    {
        message += command.Parameters[i].ToString() + "\n";
    }
    Console.WriteLine(message);
}
Public Sub CreateSqlCommand(ByVal connection As SqlConnection, _
ByVal queryString As String, ByVal params() As SqlParameter)

    Dim command As New SqlCommand(queryString, connection)
    command.CommandText = _
       "SELECT CustomerID, CompanyName FROM Customers " _
       & "WHERE Country = @Country AND City = @City"
    command.UpdatedRowSource = UpdateRowSource.Both
    command.Parameters.AddRange(params)

    Dim message As String = ""
    For i As Integer = 0 To command.Parameters.Count - 1
        message += command.Parameters(i).ToString() & ControlChars.Cr
    Next 

    Console.WriteLine(message)
End Sub

적용 대상

추가 정보