J
Jon Skeet
I'm trying to speed up a data migration tool I'm writing that uses COM
interop. Currently I'm accessing each field within a record
individually, which works, but means going across the managed/unmanaged
boundary a heck of a lot.
The COM object I'm working with has a method which I'm sure *should*
help, but I can't get it to work. It's described in the documentation
as:
GetDataEx method:
Description: Returns an array of strings containing the data for each
field specified in an array of fields.
Syntax: GetDataEx iFieldArray, szValueArray
Parameters: iFieldArray Returns an array of short integers (or
pointers to short integers in Visual C++)
that represent the field IDs of fields
for which to get the data contained in the
fields.
szValueArray Returns an array of strings (or BSTRs in
Visual C++) for the data that is returned for
the specified fields. The same number of
elements must be specified for the
iFieldArray and the szValueArray parameters.
Note: In Visual C++, use VARIANT.pparray instead of Variant.parray for
pointers to elements in the array.
Return type: void
Example: [irrelevant stuff snipped]
Dim IdArray(10) as Integer
Dim OutputArray(10) as String
' Snip getting the appropriate db object
IdArray(0) = 5
IdArray(1) = 6
IdArray(2) = 10
IdArray(3) = 15
db.GetDataEx IdArray OutputArray
Now, I've tried a number of ways of doing this, but none of them have
worked. The most obvious one is something like:
short[] fields = new short[]{1};
string[] values = new string[1];
db.GetDataEx (fields, values);
but that sets an error code of "invalid parameter" - as does everything
else I try.
Any light anyone could shed on this would be much appreciated...
interop. Currently I'm accessing each field within a record
individually, which works, but means going across the managed/unmanaged
boundary a heck of a lot.
The COM object I'm working with has a method which I'm sure *should*
help, but I can't get it to work. It's described in the documentation
as:
GetDataEx method:
Description: Returns an array of strings containing the data for each
field specified in an array of fields.
Syntax: GetDataEx iFieldArray, szValueArray
Parameters: iFieldArray Returns an array of short integers (or
pointers to short integers in Visual C++)
that represent the field IDs of fields
for which to get the data contained in the
fields.
szValueArray Returns an array of strings (or BSTRs in
Visual C++) for the data that is returned for
the specified fields. The same number of
elements must be specified for the
iFieldArray and the szValueArray parameters.
Note: In Visual C++, use VARIANT.pparray instead of Variant.parray for
pointers to elements in the array.
Return type: void
Example: [irrelevant stuff snipped]
Dim IdArray(10) as Integer
Dim OutputArray(10) as String
' Snip getting the appropriate db object
IdArray(0) = 5
IdArray(1) = 6
IdArray(2) = 10
IdArray(3) = 15
db.GetDataEx IdArray OutputArray
Now, I've tried a number of ways of doing this, but none of them have
worked. The most obvious one is something like:
short[] fields = new short[]{1};
string[] values = new string[1];
db.GetDataEx (fields, values);
but that sets an error code of "invalid parameter" - as does everything
else I try.
Any light anyone could shed on this would be much appreciated...