Show / Hide Table of Contents

    IDataStore.SetItem(int row, short column, object value) Method

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

    0.5.0-alpha

    1.0.1 (current)

    Sets the value of a row and column (by column name) to the specified value.

    Namespace: PowerBuilder.Data

    Assembly: PowerBuilder.Data.dll

    Syntax

      public bool SetItem(int row, short column, object value);
    

    Parameters

    row System.Int32

    The zero-based row location in which you want to set the value.

    column System.Int16

    The name of the column location in which you want to set the value.

    value System.Object

    The value to which you want to set the data at the row and column location. The datatype of the value must be the same as the datatype of the column.

    Returns

    System.Boolean

    Returns true if it succeeds.

    Examples

    The following code example uses the SetItem method to modify the value for column 2 in row 1.

    using PowerBuilder.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreExamples
    {
        public class SetItemExample
        {
            private SchoolContext _context;
    
            public SetItemExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example1()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore("d_department", _context);
    
                // Retrieves rows from the database for datastore
                datastore.Retrieve();
    
                Console.WriteLine("After Retrieve, Rowcount: {0}",
                                  datastore.RowCount);
    
                // Sets the value for column 2 in row 1 to "Engineering New"
                datastore.SetItem(0, 1, "Engineering New");
    
                Console.WriteLine("Gets the original value of name: {0}",
                    datastore.GetItemString(0, 1, DwBuffer.Primary, true));
    
                Console.WriteLine("Gets the modified value of name: {0}",
                    datastore.GetItemString(0, 1, DwBuffer.Primary, false));
    
                /*This code produces the following output:
                
                After Retrieve, Rowcount: 4   
                Gets the original value of name: Engineering
                Gets the modified value of name: Engineering New
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon