Open persisted ADODB recordset in ADO.Net DataSet

  • Thread starter Thread starter Dan Reber
  • Start date Start date
D

Dan Reber

The below code is what I put together to open a XML persisted ADODB 2.8
recordset in an ADO.Net v2 DataSet. My question is if the below code the
best why to go about this.

Thanks

Dan Reber
ADODB.Recordset rs = new ADODB.Recordset();

rs.Open(fileName, Type.Missing, CursorTypeEnum.adOpenStatic,
LockTypeEnum.adLockBatchOptimistic, -1);

try

{

DataSet myDataSet = new DataSet();

OleDbDataAdapter adapter = new OleDbDataAdapter();

adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

int count = adapter.Fill(myDataSet, rs, "ADODB.RecordSet");

return myDataSet;

}

catch (Exception e)

{

Console.Write(e.ToString());

return null;

}
 
Correct, I want to open a recordset that was saved in ADO 2.8 (Not ADO.NET)
in a ADO.NET Dataset.

Dan
 
Ok, I'm not sure I can help with that. What happens when you run your
code?
Does it work?

Robin S.
--------------------------------
 
Essentially, getting a recordset into ADO.NEt DataSet involves
OleDbDataAdapter to load DataSet from the recordset.

See: http://support.microsoft.com/kb/310349

Now, if you have the RS as XML, you could instantiate Recordset in .NEt code
(you need reference to ADO library), load the XML to it and then use
OleDbdataAdapter to load that into a DataSet. Of course, if you already have
a COM component returning that recordset, you don't need to persist it on
disk etc


--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
 
Thanks for the info; I didn't know you could do that. So now I guess the
question is if the OP's code actually works, because it seems very similar
to the MSDN article.

Robin S.
-----------------------------
 
Thanks Teemu, looks like I did it the correct way. I was just checking to
make sure there wasn't an alternative that was more efficient. By the way,
the reason why I am doing it this way is so I can convert my application
from VB 6 to C# in phases. I already have a process that creates ADO 2.8
recordsets and persists them back to the database, I want to use that
functionality while I convert other parts of the application to C#.

Regards,

Dan
 
Back
Top