ArcObjects Library Reference  (GeoDatabase)    

ITable GetRow Example

[Visual Basic 6.0]
Dim pWorkspace As IWorkspace Dim pFact As IWorkspaceFactory ' This example uses an SDE connection. This code works the ' same for any open IWorkspace. Dim pPropset As IPropertySet Set pPropset = New PropertySet With pPropset .SetProperty "Server", "fred" .SetProperty "Instance", "5203" .SetProperty "Database", "sdedata" .SetProperty "user", "test" .SetProperty "password", "test" .SetProperty "version", "sde.DEFAULT" End With Set pFact = New SdeWorkspaceFactory Set pWorkspace = pFact.Open(pPropset, Me.hWnd) Dim pFeatureWorkspace As IFeatureWorkspace Set pFeatureWorkspace = pWorkspace Dim pTable As ITable Set pTable = pFeatureWorkspace.OpenTable("Pavement") Dim pRow As IRow Set pRow = pTable.GetRow(59) Debug.Print pRow.Value(2)

[C#]

    //ITable GetRow Example

    //e.g., nameOfTable = "Owners"
    //on ArcSDE use ISqlSyntax::QualifyTableName for fully qualified table names.
    public void ITable_GetRow_Example(IWorkspace workspace, string nameOfTable)
    {
        IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
        ITable table = featureWorkspace.OpenTable(nameOfTable);
        //get row should be used to get a single row for which the Object ID is know.
        //if you would like to iterate through many rows use a cursor.
        IRow row = table.GetRow(59);
        Console.WriteLine(row.get_Value(row.Fields.FindField("Name")));
    }


[Visual Basic .NET, C++]
No example is available for Visual Basic .NET or C++. To view a Visual Basic 6.0 or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.