IDataAdapter.GetFillParameters Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Tee yhteistyötä kanssamme GitHubissa
Tämän sisällön lähde on GitHubissa, jossa voit myös luoda ja tarkastella ongelmia ja pull-pyyntöjä. Katso lisätietoja osallistujan oppaasta.