Hello,
I am trying to use the LinkData function of a MapPoint DataSets object from c++. I get error "The parameter is incorrect".
With VB it works without problem.

Here is a VB code

Private Sub ImportData_Click()
Dim objMap As MapPointCtl.Map
Dim objLoc As MapPointCtl.Location
Dim objPushPin As MapPointCtl.Pushpin
Dim zDataSource As String
Dim Key As String
Dim FLArray(1 To 3, 1 To 2) As Variant
Dim FLDS As MapPointCtl.DataSet

zDataSource = "C:\test.txt"
Key = "Name"
Set objMap = Form1.MappointControl1.ActiveMap


FLArray(1, 1) = 1 '"Name"
FLArray(1, 2) = geoFieldName
FLArray(2, 1) = 2 '"Latitude"
FLArray(2, 2) = geoFieldLatitude
FLArray(3, 1) = 3 '"Longitude"
FLArray(3, 2) = geoFieldLongitude

Set FLDS = objMap.DataSets.LinkData(zDataSource, _
Key, FLArray, , geoDelimiterSemicolon, _
geoImportFirstRowIsHeadings)
' FLDS.ZoomTo

End Sub


And here a C++ code

const long geoImportFirstRowIsHeadings = 0;
const long geoImportFirstRowNotHeadings = 1;
const long geoDelimiterSemicolon = 59;
const long geoCountryGermany = 94;
const long geoCountryDefault = 0;
const long geoFieldName = 1;
const long geoFieldLatitude = 20;
const long geoFieldLongitude = 21;

SAFEARRAYBOUND saBound[ 2 ] ;
saBound[ 0 ].cElements = 3 ; saBound[ 0 ].lLbound = 1;
saBound[ 1 ].cElements = 3 ; saBound[ 1 ].lLbound = 1;

_variant_t arr;
VariantInit(&arr);
arr.vt = VT_ARRAY | VT_VARIANT;

arr.parray = SafeArrayCreate (VT_VARIANT, 2, saBound);//

long idx[ 2 ] ;

_variant_t Name;// = (long)1;//"Name";
_variant_t latitude;// = (long)2;//"Latitude";
_variant_t longitude;// = (long)3;//"Latitude";

_variant_t Name_val;// = geoFieldName;
_variant_t latitude_val;// = geoFieldLatitude;
_variant_t longitude_val;// = geoFieldLongitude;


idx[ 0 ] = 1 ; idx[ 1 ] = 1;
VERIFY(SafeArrayPutElement(arr.parray, idx, &Name) == S_OK);

idx[ 0 ] = 1 ; idx[ 1 ] = 2;
VERIFY(SafeArrayPutElement(arr.parray, idx, &Name_val) == S_OK);

idx[ 0 ] = 2 ; idx[ 1 ] = 1;
VERIFY(SafeArrayPutElement(arr.parray, idx, &latitude) == S_OK);

idx[ 0 ] = 2 ; idx[ 1 ] = 2;
VERIFY(SafeArrayPutElement(arr.parray, idx, &latitude_val) == S_OK);

idx[ 0 ] = 3 ; idx[ 1 ] = 1;
VERIFY(SafeArrayPutElement(arr.parray, idx, &longitude) == S_OK);

idx[ 0 ] = 3 ; idx[ 1 ] = 2;
VERIFY(SafeArrayPutElement(arr.parray, idx, &longitude_val) == S_OK);

_variant_t key = "Name";
CDataSets dss = m_MapPoint.GetActiveMap().GetDataSets();

CString zDataSource = "C:\test.txt";
CDataSet ds = dss.LinkData(zDataSource.c_str(), key, arr, geoCountryDefault,
geoDelimiterSemicolon, geoImportFirstRowIsHeadings);

Any ideas?

Thanks
Sergej