Show / Hide Table of Contents

    IDataStore.SetItem(int row, string 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 number) to the specified value.

    Namespace: PowerBuilder.Data

    Assembly: PowerBuilder.Data.dll

    Syntax

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

    Parameters

    row System.Int32

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

    column System.String

    The zero-based 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 the name column in the last row.

    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 Example2()
            {
                // 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 the name column in the last row to "New Department"
                datastore.SetItem(datastore.RowCount - 1, "name", "Engineering New");
    
                int lastRow = datastore.RowCount - 1;
                Console.WriteLine("Gets the original value of name: {0}",
                    datastore.GetItemString(lastRow, "name", DwBuffer.Primary, true));
    
                Console.WriteLine("Gets the modified value of name: {0}",
                    datastore.GetItemString(lastRow, "name", DwBuffer.Primary, false));
    
                /*This code produces the following output:
    
                After Retrieve, Rowcount: 4   
                Gets the original value of name: Mathematics
                Gets the modified value of name: New Department
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon