PDA

View Full Version : Refreshing Linked datasets



David Haarmeyer
10-12-2010, 04:00 PM
I'm developing an application in Visual FoxPro 7.0 which opens Mappoint 2010 with a csv file linked as a dataset. When the application re-writes the csv file, I need to have Mappoint refresh automatically (without hitting <SHIFT><F9>). Any Ideas?

I use the following code to create the object

objApp = CREATEOBJECT('MapPoint.Application')

objApp.Visible = 'True'
objApp.UserControl = 'True'

With objApp.ActiveMap.DataSets
oDS=.LinkData(szconn,"key", ,244,44,0)

ENDWITH

and attempt to update the link with

objApp.Visible = 'True'
objApp.UserControl = 'True'
objApp.setfocus = 'True'
With objApp.ActiveMap.DataSet
oDs=.UpdateLink
ENDWITH

but it doesn't update.

Also - is there any way to tell mappoint which fields to use to populate the map so that I don't need to manually go into the settings after each refresh?

Wilfried
10-19-2010, 06:15 AM
Hi,

UpdateLink is indeed the right method to call. I have a few applications where I use it and it works.

To set the fields you can make an array in 3th parameter of the LinkData method. In that array you can specifie the fields.

This is an example in C#:

object[,] fieldSpecifications = new object[fieldNames.Length, 2];
fieldSpecifications[fieldNoId, 0] = fieldNames[fieldNoId];
//fieldSpecifications[fieldNoId, 1] = MapPoint.GeoFieldType.geoFieldData;
fieldSpecifications[fieldNoId, 1] = MapPoint.GeoFieldType.geoFieldName;
fieldSpecifications[fieldNoLat, 0] = fieldNames[fieldNoLat];
fieldSpecifications[fieldNoLat, 1] = MapPoint.GeoFieldType.geoFieldLatitude;
fieldSpecifications[fieldNoLon, 0] = fieldNames[fieldNoLon];
fieldSpecifications[fieldNoLon, 1] = MapPoint.GeoFieldType.geoFieldLongitude;

MapPoint.DataSet dataSet = MapPointMap.DataSets.LinkData(dlg.FileName,
fieldNoId + 1,
fieldSpecifications,
MapPoint.GeoCountry.geoCountryDefault,
MapPoint.GeoDelimiter.geoDelimiterSemicolon,
MapPoint.GeoImportFlags.geoImportFirstRowIsHeading s);

David Haarmeyer
10-19-2010, 08:29 AM
With UpDateLink, do I need to specify anything else?

I should be able to translate the arraybuild and useage to VFP - Thanx

Wilfried
11-02-2010, 03:11 AM
Hi,

No, just dataSet.UpdateLink(); Of course take the right dataset :)