Convert _Recordset to DataSet/DataTable

  • Thread starter Thread starter B. Salmon
  • Start date Start date
B

B. Salmon

I have a Visual C++ .NET function that is calling an unmanaged function that
returns an ADO _Recordset* object. I want to be able to convert that into
an ADO.NET DataSet (or DataTable). I tried to use the OleDbDataAdapter.Fill
method, but I could only get that to work if I gave it an
ADODB::RecordsetClass object. I couldn't figure out how to get an ADO
_Recordset into an ADODB::RecordsetClass.

Any ideas? I don't want to have to rewrite all of our existing unmanaged
code.

- Brad
 
Cor,
Thanks, but I have already looked at that approach. The problem with that
Fill method is that the method takes a "managed" Recordset. In other words,
I need to add a reference to the ADO COM component so a interop wrapper is
created, ADODB. I can then pass an ADODB::RecordsetClass object into the
Fill. My problem is that I'm in C++ and want to call a method in an
existing library that knows nothing about .Net and is returning a
_Recordset* object. In that case, I haven't figured out a way to make the
_Recordset* object become an ADODB::RecordsetClass object so I can call the
Fill method you refer to.

- Brad
 
Brad,

Sorry I would not know how to solve your problem, this was all I knowed.
However maybe the dotnet data newsgroup is an alternative when you get no
further answer here..

That newsgroup is in my opinion more dedicated to the recordset.

Creating a DataTable or Dataset is of course a piece of case.

Cor
 
I have a Visual C++ .NET function that is calling an unmanaged function
that
returns an ADO _Recordset* object. I want to be able to convert that into
an ADO.NET DataSet (or DataTable). I tried to use the
OleDbDataAdapter.Fill method, but I could only get that to work if I gave
it an ADODB::RecordsetClass object. I couldn't figure out how to get an
ADO _Recordset into an ADODB::RecordsetClass.

Any ideas? I don't want to have to rewrite all of our existing unmanaged
code.

Did you try to pass your native _Recordset converted to object with
Marshal.GetObjectForIUnknown() into OleDbDataAdapter.Fill function?
 
THANK YOU!! That did the trick!

- Brad

Vladimir Nesterovsky said:
Did you try to pass your native _Recordset converted to object with
Marshal.GetObjectForIUnknown() into OleDbDataAdapter.Fill function?
 
Back
Top