Show / Hide Table of Contents

    DbResultSet.Close() Method

    .NET Standard 2.x

    Closes the result set.

    Similar to close the SQL procedure ProcedureName or close the SQL cursor CursorName in PowerBuilder.

    Namespace: PowerScript.Bridge

    Assembly: PowerScript.Bridge.dll

    Syntax

      public virtual void Close();
    

    Examples

    The following code example executes a stored procedure and returns the result set. The result set returned by the stored procedure is stored in the DbResultSet object and how to close the DbResultSet object.

    using System;
    using SnapObjects.Data;
    using PowerScript.Bridge;
    
    namespace Appeon.ApiDoc.DbResultSetExamples
    {
        public class CloseExample
        {
            private readonly SchoolContext _context;
    
            public CloseExample(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));
    
                resultSet.Next();
    
                // Shows the result set of 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

    Back to top Generated by Appeon