PC Review


Reply
Thread Tools Rate Thread

Creating ADODB recordset in code

 
 
Raymon
Guest
Posts: n/a
 
      7th Aug 2012

I am trying to create an ADODB recordset but I am getting an error.
(Don't say to use ADO.Net. I have to use classic ADO; it is a legacy
requirement.)

In old VB6 I used to create a disconnected ADODB recordset like:

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Fields.Append "Col1", adVarChar, 30
rs.Open

In C# I try:

ADODB.Recordset rs = new ADODB.Recordset();
rs.Fields.Append("Col1", adVarChar, 30);

But the last statement gives a MissingMethod exception, as if
there is no Append method. Although it shows up in the
Intellisense.
This is not caught during compile, only at runtime.

Is there a way to create an ADODB recordset in code in .Net?

BTW, I am using .Net Framework 4.0.
 
Reply With Quote
 
 
 
 
bradbury9
Guest
Posts: n/a
 
      7th Aug 2012
El martes, 7 de agosto de 2012 09:20:16 UTC+2, Raymon escribió:
> I am trying to create an ADODB recordset but I am getting an error.
>
> (Don't say to use ADO.Net. I have to use classic ADO; it is a legacy
>
> requirement.)
>
>
>
> In old VB6 I used to create a disconnected ADODB recordset like:
>
>
>
> Dim rs As ADODB.Recordset
>
> Set rs = New ADODB.Recordset
>
> rs.Fields.Append "Col1", adVarChar, 30
>
> rs.Open
>
>
>
> In C# I try:
>
>
>
> ADODB.Recordset rs = new ADODB.Recordset();
>
> rs.Fields.Append("Col1", adVarChar, 30);
>
>
>
> But the last statement gives a MissingMethod exception, as if
>
> there is no Append method. Although it shows up in the
>
> Intellisense.
>
> This is not caught during compile, only at runtime.
>
>
>
> Is there a way to create an ADODB recordset in code in .Net?
>
>
>
> BTW, I am using .Net Framework 4.0.


Check this link, seems to be what you are looking for http://support.microsoft.com/kb/308611/en-us

BTW, it's is first google result for "adodb recordset c#"
 
Reply With Quote
 
 
 
 
Jeff Johnson
Guest
Posts: n/a
 
      7th Aug 2012
"bradbury9" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

>> I am trying to create an ADODB recordset but I am getting an error.


> Check this link, seems to be what you are looking for
> http://support.microsoft.com/kb/308611/en-us


I didn't see anything in that link that talked about creating a recordset
from scratch, which is what the OP is asking about.


 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      7th Aug 2012
"Raymon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> (Don't say to use ADO.Net. I have to use classic ADO; it is a legacy
> requirement.)


May I ask what this legacy requirement is? Are you going to pass the
Recordset to a COM object?


 
Reply With Quote
 
bradbury9
Guest
Posts: n/a
 
      7th Aug 2012
El martes, 7 de agosto de 2012 18:54:55 UTC+2, Jeff Johnson escribió:
> "bradbury9" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> >> I am trying to create an ADODB recordset but I am getting an error.

>
>
>
> > Check this link, seems to be what you are looking for

>
> > http://support.microsoft.com/kb/308611/en-us

>
>
>
> I didn't see anything in that link that talked about creating a recordset
>
> from scratch, which is what the OP is asking about.



You are right, Yaymon's error seems to be related with the reference

Dim rsInputBuffer As New ADODB.Recordset
rsInputBuffer.CursorLocation = ADODB.CursorLocationEnum.adUseClient
rsInputBuffer.Fields.Append("Comment", ADODB.DataTypeEnum.adBoolean)
rsInputBuffer.Fields.Append("LineData", ADODB.DataTypeEnum.adChar, 100)
rsInputBuffer.Open()

This code works fine, but must be carefull with the reference:

"Seems that I have solved the problem adding a reference to "Microsoft ActiveX Data Objects Recordet 2.8 Library" instead of "Microsoft ActiveX Data Objects 2.8 Library"

http://social.msdn.microsoft.com/For...f-757d047b00d5
 
Reply With Quote
 
Raymon
Guest
Posts: n/a
 
      8th Aug 2012
On Tue, 7 Aug 2012 12:55:29 -0400, "Jeff Johnson" <(E-Mail Removed)>
wrote:

>"Raymon" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>
>> (Don't say to use ADO.Net. I have to use classic ADO; it is a legacy
>> requirement.)

>
>May I ask what this legacy requirement is? Are you going to pass the
>Recordset to a COM object?
>


Yes.
An application is being converted from VB6/ADODB to C#/ADO.Net, piece
by piece.
Until the whole thing is converted to .Net we have to live in this
hybrid environment, converting from ADODB to ADO.Net and
vice versa.
I had no problem converting ADODB recordset to ADO.Net DataTable.
But ran into the the problem going the other way around.

Anyway, doing some more research I found out the problem.
It seems that ADODB is broken in .Net framework 4.0 which is
our target framework.
If I change the target framework to 3.5 or lower, the code I gave
works without problem.

 
Reply With Quote
 
bradbury9
Guest
Posts: n/a
 
      8th Aug 2012
El miércoles, 8 de agosto de 2012 04:57:14 UTC+2, Raymon escribió:
> Anyway, doing some more research I found out the problem.
>
> It seems that ADODB is broken in .Net framework 4.0 which is
>
> our target framework.
>
> If I change the target framework to 3.5 or lower, the code I gave
>
> works without problem.


Which is one of the solutions that my last link says. From my previous link:

"So it sounds like there are two answers here:
- When using Visual Studio 2010 , you can change the Target .NET Framework of your project from ".NET Framework 4.0" to ".NET Framework 3.5" or ".NET Framework 3.5 Client Profile"
- Or you can do as tix61 suggests and change your reference to "Microsoft ActiveX Data Objects Recordet 2.8 Library" instead of "Microsoft ActiveX Data Objects 2.8 Library""

Have you tried changing the reference? It may work in Framework 4.0
 
Reply With Quote
 
Raymon
Guest
Posts: n/a
 
      9th Aug 2012
On Wed, 8 Aug 2012 01:49:57 -0700 (PDT), bradbury9
<(E-Mail Removed)> wrote:

>El miércoles, 8 de agosto de 2012 04:57:14 UTC+2, Raymon escribió:
>> Anyway, doing some more research I found out the problem.
>>
>> It seems that ADODB is broken in .Net framework 4.0 which is
>>
>> our target framework.
>>
>> If I change the target framework to 3.5 or lower, the code I gave
>>
>> works without problem.

>
>Which is one of the solutions that my last link says. From my previous link:
>
>"So it sounds like there are two answers here:
>- When using Visual Studio 2010 , you can change the Target .NET Framework of your project from ".NET Framework 4.0" to ".NET Framework 3.5" or ".NET Framework 3.5 Client Profile"
>- Or you can do as tix61 suggests and change your reference to "Microsoft ActiveX Data Objects Recordet 2.8 Library" instead of "Microsoft ActiveX Data Objects 2.8 Library""
>
>Have you tried changing the reference? It may work in Framework 4.0


"Microsoft ActiveX Data Objects Recordset 2.8 Library" is reference to
ADOR object model.
That's not the same thing as ADODB with the refernce
"Microsoft ActiveX Data Objects 2.8 Library".
 
Reply With Quote
 
New Member
Join Date: Mar 2014
Posts: 1
 
      27th Mar 2014
Could anyone help me to create ADODB recordset almost same as example mentioned above in VC++6.0
Appreciate ur help!!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2002: bind adodb recordset to listbox recordset property Craig Buchanan Microsoft Access Form Coding 2 1st May 2005 12:14 AM
help convert DAO.Recordset to ADODB.Recordset =?Utf-8?B?Uk5VU1pAT0tEUFM=?= Microsoft Access Forms 1 27th Feb 2005 08:51 PM
Problem with Set combobox.recordset = <adodb.recordset> Gijs Beukenoot Microsoft Access Form Coding 0 10th Nov 2004 07:22 PM
Equivalent ADODB.Connector and ADODB.Recordset in VB.NET Marty Microsoft Dot NET 3 25th Sep 2004 10:36 PM
Equivalent ADODB.Connector and ADODB.Recordset in VB.NET Marty Microsoft VB .NET 3 25th Sep 2004 10:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:02 PM.