Using ADO.NET DataSet in Unmanaged C++ COM Code

G

Guest

Hello,

I am accessing the database using ADO.NET/Managed C++. I would like to use
the returned data in form of cursors in Unmanaged C++ (standard C++ with
COM). Through COM Callable Wrappers & Interop the Stored Procs will be
called. The in-out data volume handled through this module will be large, so
the high performance is required.

Is there any standard way to write marshaling to use ADO.NET DataSets in
COM/C++ world? How to leverage XML?

Thanks.
-AJ
 
G

Guest

Thanks Sahil,

Yes, I am using SqlDataReader and XmlReader in Data Tier which is in .NET.
As some of the Business Tier is in Standard C++ and COM, I was looking for
consuming the ADO.NET DataSets or XML in Unmanaged C++. The COM Callable
Wrapper returns pointer to IUnknown, which needs marshaling. To communicate
with Data Tier in .NET from Business Tier in Win32 there might be some
standard way. That is what I was looking for.

As there is lot of server side data processing, I was exploring efficient
way to get and put large data from Business Tier into database through Data
Tier. The database calls are using Stored Procs. Data Tier will be in Managed
C++ with ADO.NET.

-AJ
 
S

Sahil Malik

Hey AJ,

First of all, there isn't enough benefit in my eyes in subjecting yourself
to C++ if you are dealing with pure managed code. (Your data tier).
Secondly, DataReader is connected .. sure .. but can be easily made
disconnected (search my blog for "How to create a databindable data
reader"). BTW, that is also the mostest efficientest way atleast AFAIK to
get disconnected data from the d/b. The only more efficient and pure .NET
way is to use a connected datareader. And in multi user scenarioes that just
might not be very efficient (since it'd have the tendency to block open
connections for a longer period).

Finally, a huge object such a dataset might have one odd thing in it that is
set to ComVisible(False). in other words, I am a bit leery about exposing a
huge object as a dataset via interop to a COM thing. It is certainly
possible, but you might run into practical problems that any amount of
theory (typically books) won't apprise you of. Most books touch the most
simplistic approach and leave it there.

I personally would be more comfortable with creating your own business
objects, populating them in the managed business layer using the dataset
received from the data layer, and sending that to C++/COM libraries that you
might already have.

Call me a pessimist, but when it comes to dealing with COM/.NET Interop, I
am much more comfortable in dealing with objects that I have full control
over. I've had plenty of unexplained problems there :-/ . like Method "~" of
object "~" failed .. (How do you decipher that .. especially if it were
coming from deep within the very complicated RCW for the dataset). Also, how
..NET objects are exposed to COM via interop, how it has to go thru
mscoree.dll, which shims a COM component and finds the dll for you, it isn't
the simple RegSvr32 registration, in other words, it is so not a COM
component anymore .. that I'd much rather stick with simpler objects going
over that layer. .. oh and not to mention garbage collection for COM/.NET
mixture .. .. enough reasons already :)

So my recommended solution is
Database <--> C# .NET DataLayer <-(dataset or something else) ->
Business Layer --> UltraDumbAndSimpleAndFullySerializableBizObject
<---interop--> Win32.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top