SqlContext.SetParm(int index, object value) Method
.NET Standard 2.x
Specifies a value for an input parameter in the SqlContext.
Namespace: PowerScript.Bridge
Assembly: PowerScript.Bridge.dll
Syntax
public void SetParm(int index, object value)
Parameters
index
System.Int32
An integer identifying the input parameter descriptor in which you want to set the data.
value
System.Object
The value you want to use to fill the input parameter descriptor identified by index.
Examples
The following code example demonstrates how to use the SqlContext
object to specify a SQL SELECT statement and use the SetParm
method to define the parameters (type is object).
using System;
using PowerScript.Bridge;
namespace Appeon.ApiDoc.SqlContextExamples
{
public class SetParmExample
{
private readonly SchoolContext _context;
public SetParmExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example1()
{
// Defines the SQL SELECT statement.
var sql = @"select EnrollmentID, Grade from StudentGrade " +
"where StudentID = @StudentID and CourseID=@CourseID";
// Creates a SqlContext object
var sqlContext = _context.CreateSqlContext(sql);
// Defines two parameters for the SQL statement. Type is object.
object parm1 = 2;
object parm2 = 2021;
sqlContext.SetParm(0, parm1);
sqlContext.SetParm(1, parm2);
// Shows the parameters
Console.WriteLine($"Parameter count = {sqlContext.Parms.Length}, " +
$"Value of first parameter = {sqlContext.Parms[0].Value}, " +
$"Value of second parameter = {sqlContext.Parms[1].Value}.");
/*This code produces the following output:
Parameter count = 2, Value of first parameter = 2, Value of second parameter = 2021.
*/
}
}
}
Applies to
.NET Standard
2.x