473,383 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Help required with interop

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...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #1
3 2284
> Does that help at all?
Not really. If you have the tlb file then you can load it up using the
Ole/Com object viewer found under the tools menu of dev studio. This might
give you a bit more info on the method.

Regards
Lee
"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP************************@news.microsoft.com ...
Lee Alexander <lee@No_Spam_Please_Digita.com> wrote:
From the documentation it looks like it expects and array of pointers to
integers. Whereas you are passing a pointer to an array of integers.


Yup - I wondered about that. I tried declaring it as object[] so that
boxing would take place, hoping that the reference would effectively be
a pointer to a short. It didn't help...
Could
this be the problem? Do you have the IDL for the offending function??


I don't, but I have the relevant sections of the tli/tlh files (with
names changed to protect the innocent. From the tli file:

inline HRESULT [Removed]::I[Removed]::GetDataEx
(const _variant_t & vFieldArray, const _variant_t & vValueArray )
{
return _com_dispatch_method(this, 0xe0, DISPATCH_METHOD, VT_EMPTY,
NULL, L"\x000c\x000c", &vFieldArray,
&vValueArray);
}

Does that help at all?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

Nov 15 '05 #2
Lee Alexander <lee@No_Spam_Please_Digita.com> wrote:
Does that help at all?

Not really. If you have the tlb file then you can load it up using the
Ole/Com object viewer found under the tools menu of dev studio. This might
give you a bit more info on the method.


Aha. Cheers - sorry, it's a while since I've done any "real" COM work,
and I didn't do much then :)

Hmm. It doesn't seem to give much more info:

[id(0x000000e0)]
void GetDataEx(
VARIANT vFieldArray,
VARIANT vValueArray);

Distinctly unhelpful :(

Never mind - I've found another way of speeding things up considerably:
loading the whole database into memory to start with! I think a lot of
the time was being spent jumping around different records in the
database...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #3
> Never mind - I've found another way of speeding things up considerably:
okies.

Regards
Lee

"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP************************@news.microsoft.com ...
Lee Alexander <lee@No_Spam_Please_Digita.com> wrote:
Does that help at all?

Not really. If you have the tlb file then you can load it up using the
Ole/Com object viewer found under the tools menu of dev studio. This might give you a bit more info on the method.


Aha. Cheers - sorry, it's a while since I've done any "real" COM work,
and I didn't do much then :)

Hmm. It doesn't seem to give much more info:

[id(0x000000e0)]
void GetDataEx(
VARIANT vFieldArray,
VARIANT vValueArray);

Distinctly unhelpful :(

Never mind - I've found another way of speeding things up considerably:
loading the whole database into memory to start with! I think a lot of
the time was being spent jumping around different records in the
database...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve Long | last post by:
Hello, I have a VB.NET class that raises a MapSet event that passes an argument of type interop.MapObjects2.MapClass. I have a C# class that inherits from this VB.NET class. How can I handle the...
17
by: VM | last post by:
In my Windows app, I'm running a batch process that's composed of a FOR loop that'll run 15,000 times (datatable row count), copy cthe data of each row -3 fields- to a struct, and send the strct to...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
1
by: Rajendra Prasad | last post by:
Hi friends, I am new to the ASP.NET environment. During web application development, I am frequently facing the following problem. Configuration Error Description: An error occurred during the...
3
by: vighnesh | last post by:
Hi All I am dealing a project in ASP.NET which uploads office documents and convert them as PDF files,to accomplish this convertion I have used a third party component named "easy PDF SDK".Every...
4
by: john | last post by:
I'm having some Interop problems. I really need someone's help on this, i'm running out of ideas. I have upgraded my Data access controls to the latest ver. Now then i have a form with these...
0
by: R Reyes | last post by:
ISSUE (reposted) =========================== Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? For many people, they say they add the...
5
by: Michael Russell | last post by:
Hi all, Using C#, I've created a simple wrapper class for using Excel. I have Office Pro 2003 installed on my devel machine. The wrapper class works great, reading and writing to/from Excel. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.