Show / Hide Table of Contents

    IDataStore.ReselectRow(int row) Method

    .NET Standard 2.x | Current Version (1.0.1)

    0.5.0-alpha

    1.0.1 (current)

    Accesses the database to retrieve values for all columns that can be updated and refreshes all timestamp columns in a row in the DataStore.

    Namespace: PowerBuilder.Data

    Assembly: PowerBuilder.Data.dll

    Syntax

      public int ReselectRow(int row);
    

    Parameters

    row System.Int32

    A zero-based number identifying the row to reselect.

    Returns

    System.Int32

    Returns 1 if it succeeds and -1 if the row cannot be reselected (for example, the DataStore cannot be updated or the row was deleted by another user).

    Remarks

    ReselectRow is supported for SQL Select DataStore. Use ReselectRow to discard values the user has changed and replace them with values from the database after an update fails (due to a concurrent access error, for example).

    Examples

    The following code example modifies the values for row 1 and then calls the ReselectRow method to retrieve the original values for row 1 from database again.

    using PowerBuilder.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreExamples
    {
        public class ReselectRowExample
        {
            private SchoolContext _context;
    
            public ReselectRowExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore("d_department", _context);
    
                datastore.Retrieve();
    
                Console.WriteLine("Department ID: {0}; Department Name: {1}",
                                   datastore.GetItem<int>(0, "departmentid"),
                                   datastore.GetItem<string>(0, "name"));
    
                // Modified the values for row 1.
                datastore.SetItem(0, "departmentid", 10);
                datastore.SetItem(0, "name", "Department Name");
    
                Console.WriteLine("Department ID: {0}; Department Name: {1}",
                                   datastore.GetItem<int>(0, "departmentid"),
                                   datastore.GetItem<string>(0, "name"));
    
                // Calls ReselectRow to retrieve values for row 1 from database again.
                // It will send SQL commands to database.
                datastore.ReselectRow(0);
    
                Console.WriteLine("Department ID: {0}; Department Name: {1}",
                                   datastore.GetItem<int>(0, "departmentid"),
                                   datastore.GetItem<string>(0, "name"));
    
                /*This code produces the following output:
                 
                Department ID: 1; Department Name: Engineering
                Department ID: 10; Department Name: Department Name
                Department ID: 1; Department Name: Engineering
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon