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
GitHub पर हमारे साथ सहयोग करें
इस सामग्री का स्रोत GitHub पर पाया जा सकता है, जहाँ आप समस्याएँ बना और समीक्षा भी कर सकते हैं और अनुरोध खींच सकते हैं. अधिक जानकारी के लिए, हमारे योगदानकर्ता गाइड देखें.