DbResultSet.Next() Method
.NET Standard 2.x
Gets the data value of the next row from the result set. Similar to the cursor FETCH NEXT
function.
Namespace: PowerScript.Bridge
Assembly: PowerScript.Bridge.dll
Syntax
public abstract void Next();
Examples
The following code example demonstrates how to execute a stored procedure and get the result set (stored in the DbResultSet
object) and how to get the next row of data from the result set.
using System;
using SnapObjects.Data;
using PowerScript.Bridge;
namespace Appeon.ApiDoc.DbResultSetExamples
{
public class NextExample
{
private readonly SchoolContext _context;
public NextExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
int studentID = 2;
// Executes a stored procedure which gets the data of StudentGrade table according to StudentID.
_context.SqlExecutor.ExecuteProcedure("GetStudentGrades",
out DbResultSet resultSet, ParamValue.New<int>("StudentID", studentID));
// Gets another row of data.
resultSet.Next();
// Shows the result set returned by the stored procedure.
while (resultSet.SqlCode == 0)
{
Console.WriteLine($"EnrollmentID: {resultSet.GetValue<int>("EnrollmentID")}, " +
$"Grade: {resultSet.GetValue<decimal>("Grade")}, " +
$"CourseID: {resultSet.GetValue<int>("CourseID")}, " +
$"StudentID: {resultSet.GetValue<int>("StudentID")}");
resultSet.Next();
}
// Closes the resultSet object.
resultSet.Close();
/*This code produces the following output:
EnrollmentID: 1, Grade: 4.00, CourseID: 2021, StudentID: 2
EnrollmentID: 2, Grade: 3.50, CourseID: 2030, StudentID: 2
*/
}
}
}
Applies to
.NET Standard
2.x