แก้ไข

แชร์ผ่าน


IDataAdapter.GetFillParameters Method

Definition

Gets the parameters set by the user when executing an SQL SELECT statement.

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

Returns

An array of IDataParameter objects that contains the parameters set by the user.

Examples

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);
	    }
    }
}

Applies to