共用方式為


IDataAdapter.GetFillParameters 方法

定義

取得在執行 SQL SELECT 陳述式時由使用者設定的參數。

public:
 cli::array <System::Data::IDataParameter ^> ^ GetFillParameters();
public System.Data.IDataParameter[] GetFillParameters ();
abstract member GetFillParameters : unit -> System.Data.IDataParameter[]
Public Function GetFillParameters () As IDataParameter()

傳回

IDataParameter 物件的陣列,含有由使用者設定的參數。

範例

private static void GetParameters(string connectionString)
{
    using (var conn = new SqlConnection(connectionString))
	{
        var queryString = "SELECT [CourseID],[Title],[Credits] FROM [MySchool].[dbo].[Course] WHERE [Year]=@Year AND [Credits]>=@Credits";
	    var year = new SqlParameter("@Year", 2012);
	    var credits = new SqlParameter("@Credits", SqlDbType.Int, 4, "Credits");
	    credits.Value = 4;
		var command = new SqlCommand(queryString, conn);
	    command.Parameters.Add(year);
	    command.Parameters.Add(credits);
	    IDbDataAdapter mySchool = new SqlDataAdapter(command);
	    IDataParameter[] parameters = mySchool.GetFillParameters();
	    Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", "ParameterName", "SourceColumn", "Direction", "DbType", "Value");
	    foreach (IDataParameter parameter in parameters)
		{
		    Console.WriteLine("{0,-15}{1,-15}{2,-15}{3,-15}{4,-15}", parameter.ParameterName, parameter.SourceColumn, parameter.Direction, parameter.DbType, parameter.Value);
	    }
    }
}

適用於