2

I am a new Arc Objects user, with little ESRI experience.

We are using VBA to create a spatial report on a Map Control using a mdb table. The mdb table contains a Lat and Long field, and this data is collected in the Access application.

For the reporting, we need to display a map with the locations from the mdb table.

My questions are:

  1. How do I access data in a mdb table, as spatial data? Does it have to be registered as spatial? I am not sure if this can be done at runtime or has to be done using Arc Catalog.
  2. At runtime, if the data from the mdb table is in a spatially recognized table, do I just create a new layer, set the symbology, and then set a "where" clause on the new layer?
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Feb 27, 2011 at 19:58

3 Answers 3

2

You do not need to access it as a spatial table.(削除) You can read them using the JET ENGINE/ODBC. (削除ここまで) Please see jburka's answer on how to access the access table.

Once you have access to the table, you can show it as an event Layer.

Here is a sample, which shows how you can make an XY event layer, once you have table in a ITable:

http://resources.esri.com/help/9.3/arcgisengine/ArcObjects/esriGeoDatabase/Create_XYEventSource.htm

answered Feb 28, 2011 at 6:32
1

If you want to ONLY show spatial data(not editable in ArcMap),you don't have to have them registed as spatial,you can simply read them using Jet engine or ODBC/OLEDB drive as any other database and then show them in ArcMap using "Custom Layer" concept.It's no too hard and you can keep all your applications which generate data untouched.

another way,you have to create shape file or personal geodatabase according to the structure of your spatial data,and every time you want to show data in ArcMap,you must crearte that shape file or update geodatabase,then create a feature layer from that table in geodatabase/shape file and add it to map object.

here you can fine more about custom layer: http://edndoc.esri.com/arcobjects/9.1/extendingarcobjects/ch04/AboutCustomLayers.htm and if you need a sample code,exactly like what you said,let me know.

answered Feb 27, 2011 at 20:58
1

The link from Devdatta contains the information for taking an ITable and adding it to your map as an event layer. But you don't need to read the data with JET/ODBC; the AccessWorkspaceFactory will open an MDB regardless of whether the file is registered as a geodatabase and contains the necessary schema. This will open the table (in VBA, as that was specified in the original question):

Dim ws As IWorkspace
Dim factory As IWorkspaceFactory
Set factory = New AccessWorkspaceFactory
Set ws = factory.OpenFromFile("{path to mdb file}", 0)
Dim fws As IFeatureWorkspace
Set fws = ws
Dim table As ITable
Set table = fws.OpenTable("{table name}")
answered Feb 28, 2011 at 21:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.