|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Open persisted ADODB recordset in ADO.Net DataSetrecordset 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; } ADODB? Isn't that ADO, not ADO.Net?
Robin S. --------------------------------- Show quote "Dan Reber" <dreber@nospam.com> wrote in message news:uzDFK2LQHHA.4672@TK2MSFTNGP06.phx.gbl... > 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 Show quote "RobinS" <RobinS@NoSpam.yah.none> wrote in message news:1-KdnSL3YoME1STYnZ2dnUVZ_u-unZ2d@comcast.com... > ADODB? Isn't that ADO, not ADO.Net? > > Robin S. > --------------------------------- > "Dan Reber" <dreber@nospam.com> wrote in message > news:uzDFK2LQHHA.4672@TK2MSFTNGP06.phx.gbl... >> 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; >> >> } >> >> > > Ok, I'm not sure I can help with that. What happens when you run your
code? Does it work? Robin S. -------------------------------- Show quote "Dan Reber" <dreber@nospam.com> wrote in message news:OHj1osUQHHA.1364@TK2MSFTNGP06.phx.gbl... > Correct, I want to open a recordset that was saved in ADO 2.8 (Not > ADO.NET) in a ADO.NET Dataset. > > Dan > > > "RobinS" <RobinS@NoSpam.yah.none> wrote in message > news:1-KdnSL3YoME1STYnZ2dnUVZ_u-unZ2d@comcast.com... >> ADODB? Isn't that ADO, not ADO.Net? >> >> Robin S. >> --------------------------------- >> "Dan Reber" <dreber@nospam.com> wrote in message >> news:uzDFK2LQHHA.4672@TK2MSFTNGP06.phx.gbl... >>> 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; >>> >>> } >>> >>> >> >> > > 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 Show quote "RobinS" <RobinS@NoSpam.yah.none> wrote in message news:JK-dnZn1c5tDwCfYnZ2dnUVZ_t6qnZ2d@comcast.com... > Ok, I'm not sure I can help with that. What happens when you run your > code? > Does it work? > > Robin S. > -------------------------------- > "Dan Reber" <dreber@nospam.com> wrote in message > news:OHj1osUQHHA.1364@TK2MSFTNGP06.phx.gbl... >> Correct, I want to open a recordset that was saved in ADO 2.8 (Not >> ADO.NET) in a ADO.NET Dataset. >> >> Dan >> >> >> "RobinS" <RobinS@NoSpam.yah.none> wrote in message >> news:1-KdnSL3YoME1STYnZ2dnUVZ_u-unZ2d@comcast.com... >>> ADODB? Isn't that ADO, not ADO.Net? >>> >>> Robin S. >>> --------------------------------- >>> "Dan Reber" <dreber@nospam.com> wrote in message >>> news:uzDFK2LQHHA.4672@TK2MSFTNGP06.phx.gbl... >>>> 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; >>>> >>>> } >>>> >>>> >>> >>> >> >> > > 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 Show quote "Teemu Keiski" <jot***@aspalliance.com> wrote in message news:2137EA02-C2C6-473B-8CCD-541E61980FB2@microsoft.com... > 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 > > > > > "RobinS" <RobinS@NoSpam.yah.none> wrote in message > news:JK-dnZn1c5tDwCfYnZ2dnUVZ_t6qnZ2d@comcast.com... >> Ok, I'm not sure I can help with that. What happens when you run your >> code? >> Does it work? >> >> Robin S. >> -------------------------------- >> "Dan Reber" <dreber@nospam.com> wrote in message >> news:OHj1osUQHHA.1364@TK2MSFTNGP06.phx.gbl... >>> Correct, I want to open a recordset that was saved in ADO 2.8 (Not >>> ADO.NET) in a ADO.NET Dataset. >>> >>> Dan >>> >>> >>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message >>> news:1-KdnSL3YoME1STYnZ2dnUVZ_u-unZ2d@comcast.com... >>>> ADODB? Isn't that ADO, not ADO.Net? >>>> >>>> Robin S. >>>> --------------------------------- >>>> "Dan Reber" <dreber@nospam.com> wrote in message >>>> news:uzDFK2LQHHA.4672@TK2MSFTNGP06.phx.gbl... >>>>> 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; >>>>> >>>>> } >>>>> >>>>> >>>> >>>> >>> >>> >> >> > 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. ----------------------------- Show quote "Teemu Keiski" <jot***@aspalliance.com> wrote in message news:2137EA02-C2C6-473B-8CCD-541E61980FB2@microsoft.com... > 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 > > > > > "RobinS" <RobinS@NoSpam.yah.none> wrote in message > news:JK-dnZn1c5tDwCfYnZ2dnUVZ_t6qnZ2d@comcast.com... >> Ok, I'm not sure I can help with that. What happens when you run your >> code? >> Does it work? >> >> Robin S. >> -------------------------------- >> "Dan Reber" <dreber@nospam.com> wrote in message >> news:OHj1osUQHHA.1364@TK2MSFTNGP06.phx.gbl... >>> Correct, I want to open a recordset that was saved in ADO 2.8 (Not >>> ADO.NET) in a ADO.NET Dataset. >>> >>> Dan >>> >>> >>> "RobinS" <RobinS@NoSpam.yah.none> wrote in message >>> news:1-KdnSL3YoME1STYnZ2dnUVZ_u-unZ2d@comcast.com... >>>> ADODB? Isn't that ADO, not ADO.Net? >>>> >>>> Robin S. >>>> --------------------------------- >>>> "Dan Reber" <dreber@nospam.com> wrote in message >>>> news:uzDFK2LQHHA.4672@TK2MSFTNGP06.phx.gbl... >>>>> 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; >>>>> >>>>> } >>>>> >>>>> >>>> >>>> >>> >>> >> >> > |
|||||||||||||||||||||||