Dim pRow As IRow Set pRow = pTable.CreateRow With pRow .Value(1) = "WOOD" .Store End With
Dim pRowBuffer As IRowBuffer Dim pCursor As ICursor Set pCursor = pTable.Insert(True) Set pRowBuffer = pTable.CreateRowBuffer pRowBuffer.Value(1) = "WOOD" pCursor.InsertRow pRowBuffer
Public Sub InMemoryExample() ' Description: Sample code showing how an in memory table can be created ' Create Workspacefactory Dim pWorkSpaceFactory As IWorkspaceFactory2 Set pWorkSpaceFactory = New InMemoryWorkspaceFactory ' Create Workspace Dim pWorkspaceName As IWorkspaceName2 Set pWorkspaceName = pWorkSpaceFactory.Create("", "MyInMemoryWorkspace", Nothing, 0) ' Get a handle on Name Dim pName As IName Set pName = pWorkspaceName ' Get a handle on FeatureWorkspace Dim pFeatureWorkspace As IFeatureWorkspace Set pFeatureWorkspace = pName.Open ' Now create a fields object and add some fields to it ' Create Fields object and set the number of fields Dim pFields As IFields Set pFields = New Fields Dim pFieldsEdit As IFieldsEdit Set pFieldsEdit = pFields pFieldsEdit.FieldCount = 2 ' Create objectID field Dim pField As IField Set pField = New Field Dim pFieldEdit As IFieldEdit Set pFieldEdit = pField With pFieldEdit .Name = "OBJECTID" .Type = esriFieldTypeOID End With Set pFieldsEdit.Field(0) = pField ' Create Type field Set pField = New Field Set pFieldEdit = pField With pFieldEdit .Editable = True .Name = "VegType" .Type = esriFieldTypeString .Length = 4 .AliasName = "Vegetation Type Code" End With Set pFieldsEdit.Field(1) = pField ' Create Table Dim pTable As ITable Set pTable = pFeatureWorkspace.CreateTable("MyInMemTable", pFields, Nothing, Nothing, "") ' Create a sample row and add data Dim pRow As IRow Set pRow = pTable.CreateRow With pRow .Value(1) = "WOOD" .Store End With ' Add table to map document Dim pMXD As IMxDocument Set pMXD = ThisDocument Dim pMap As IMap Set pMap = pMXD.FocusMap Dim pStandAloneTableCollection As IStandaloneTableCollection Set pStandAloneTableCollection = pMap Dim pStandAloneTable As IStandaloneTable Set pStandAloneTable = New StandaloneTable Set pStandAloneTable.Table = pTable pStandAloneTableCollection.AddStandaloneTable pStandAloneTable pMXD.UpdateContents End Sub
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.