Use the MatchTable method to geocode a table of addresses. The AddressTable parameter is a reference to the table object that contains the addresses to geocode. The addressFieldNames parameter is a comma-delimited string containing the names of the fields in the address table that contain the address information. The names of the fields in this string must be specified in the same order as the Field objects in the Field collections returned by the AddressFields property on the IAddressInputs interface.
When geocoding a table of addresses, you must create the feature class that will contain the geocoded features and pass it to the MatchTable method using the outputFeatureClass parameter. At a minimum, the geocoded feature class must contain an ObjectID field and the match fields defined by the MatchFields property, as well as a copy of all the fields from the address table that contain the address information.
The outputFieldNames parameter is a comma-delimited string that contains the names of the match fields in the geocoded feature class. The names of the fields in this string must be specified in the same order as the Field objects in the Field collections returned by the MatchFields property. The fieldsToCopy parameter is a PropertySet defining the fields from the address table to copy to the output feature class. The names of the properties are the names of the fields in the output feature class, and the names of the properties are the names of the corresponding fields in the address table.
Once you have used the MatchTable method to geocode a table of addresses, use the AttachLocator method on the ILocatorAttach2 on the LocatorWorkspace to attach a copy of the locator to the geocoded feature class. See the following:
[VB.NET]
Dim pConnectionProperties As ESRI.ArcGIS.esriSystem.IPropertySet
Dim pWorkspaceFactory As ESRI.ArcGIS.Geodatabase.IWorkspaceFactory
Dim pFeatureWorkspace As ESRI.ArcGIS.Geodatabase.IFeatureWorkspace
Dim pLocatorManager As ESRI.ArcGIS.Location.ILocatorManager
Dim pLocatorWorkspace As ESRI.ArcGIS.Geodatabase.ILocatorWorkspace
Dim pAddressGeocoding As ESRI.ArcGIS.Location.IAddressGeocoding
Dim pAddressTable As ESRI.ArcGIS.Geodatabase.ITable
Dim pFieldsEdit As ESRI.ArcGIS.Geodatabase.IFieldsEdit
Dim pFieldEdit As ESRI.ArcGIS.Geodatabase.IFieldEdit
Dim pMatchFields As ESRI.ArcGIS.Geodatabase.IFields
Dim lngMatchFieldIndex AsLongDim pAddressFields As ESRI.ArcGIS.Geodatabase.IFields
Dim pFieldsToCopy As ESRI.ArcGIS.esriSystem.IPropertySet
Dim pUID AsNew ESRI.ArcGIS.esriSystem.UID
Dim pFeatureClass As ESRI.ArcGIS.Geodatabase.IFeatureClass
Dim pLocatorAttach As ESRI.ArcGIS.Location.ILocatorAttach2
' Open an ArcSDE workspace.
pConnectionProperties = New ESRI.ArcGIS.esriSystem.PropertySetClass
With pConnectionProperties
.SetProperty("server", "mendota")
.SetProperty("instance", "esri_sde")
.SetProperty("database", "arcobjects")
.SetProperty("user", "sde")
.SetProperty("password", "sde")
.SetProperty("version", "SDE.Default")
EndWith
pWorkspaceFactory = New ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass
pFeatureWorkspace = pWorkspaceFactory.Open(pConnectionProperties, 0)
' Get a locator from the DatabaseLocatorWorkspace.
pLocatorManager = New ESRI.ArcGIS.Location.LocatorManagerClass
pLocatorWorkspace = pLocatorManager.GetLocatorWorkspace(pFeatureWorkspace)
pAddressGeocoding = pLocatorWorkspace.GetLocator("SDE.Redlands_ZIP")
' Open the table to geocode.
pAddressTable = pFeatureWorkspace.OpenTable("arcobjects.sde.REDLANDS_ADDRESS")
' Create a feature class to contain the geocoding results.' The feature class must contain an ObjectID field, all of the match fields returned by the locator,' and fields that contain the address input values.
pFieldsEdit = New ESRI.ArcGIS.Geodatabase.FieldClass
pFieldEdit = New ESRI.ArcGIS.Geodatabase.FieldClass
' Add an ObjectID field.
pFieldEdit.Name_2 = "OBJECTID"
pFieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeOID
pFieldsEdit.AddField(pFieldEdit)
' Add the match fields.
pMatchFields = pAddressGeocoding.MatchFields
For lngMatchFieldIndex = 0 To pMatchFields.FieldCount - 1
pFieldsEdit.AddField(pMatchFields.Field(lngMatchFieldIndex))
Next lngMatchFieldIndex
' Add the address fields.
pAddressFields = pAddressTable.Fields
pFieldsToCopy = New ESRI.ArcGIS.esriSystem.PropertySetClass
pFieldEdit = pAddressFields.Field(pAddressFields.FindField("ADDRESS"))
pFieldEdit.Name_2 = "ARC_ADDRESS"
pFieldsEdit.AddField(pFieldEdit)
pFieldsToCopy.SetProperty("ARC_ADDRESS", "ADDRESS")
pFieldEdit = pAddressFields.Field(pAddressFields.FindField("ZIP"))
pFieldEdit.Name_2 = "ARC_ZIP"
pFieldsEdit.AddField(pFieldEdit)
pFieldsToCopy.SetProperty("ARC_ZIP", "ZIP")
pUID.Value = "esriGeodatabase.Feature"
pFeatureClass = pFeatureWorkspace.CreateFeatureClass("REDLANDS_LOCATION", pFieldsEdit, pUID, _
Nothing, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, "Shape", "")
' Geocode the table into the feature class.
pAddressGeocoding.MatchTable(pAddressTable, "ADDRESS,ZIP", "", pFeatureClass, _
"Shape,Status,Score,Side", pFieldsToCopy, Nothing)
' Attach the locator to the geocoded feature class.
pLocatorAttach = pLocatorWorkspace
pLocatorAttach.AttachLocator(pAddressGeocoding, pFeatureClass, _
"ARC_ADDRESS,ARC_ZIP", "Shape,Status,Score,Side")