473,499 Members | 1,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing an ADODB.Recordset from VB6 to VB.Net

I am having trouble passing an ADODB.Recordset from a VB6 application
to a VB.Net class library using COM Interop. I am running this on XP
SP2 with the .Net Framework 1.1 and MDAC 2.8 SP1.

I've compiled the VB.Net DLL and registered it so it can be used in the
VB6 app using "regasm /tlb:VBNETClass.tlb VBNETClass.dll". From the VB6
app, I added a reference to the VB.Net DLL. (Both classes also
reference the ADO 2.8 Library.) I then built the VB6 EXE and copied it
to the directory containing the VB.Net DLL.

When I run that EXE, all of the message boxes appear fine except for
the one on the last line of PrintRecordCount below. Instead, I get the
following error:

- - - -
Run-time error '-2147467262 (80004002)';
QueryInterface for interface ADODB._Recordset failed.
- - - -
(The debugger shows it to be a System.InvalidCastException.)

Any ideas?
VB6 APP

Private Sub Command1_Click()

Dim ccw As New VBNETClass.Class1

Dim rs As New ADODB.Recordset
Set rs = CreateObject("ADODB.Recordset")
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.Fields.Append "FieldName1", adVarChar, 10
rs.Fields.Append "FieldName2", adInteger
rs.Open

rs.AddNew
rs("FieldName1") = "David"
rs("FieldName2") = 17
rs.Update

rs.Sort = "FieldName2"
rs.MoveFirst

MsgBox ("In VB6 App, about to call VB.Net class...")
MsgBox ("In VB6 Class, rs.RecordCount = " & rs.RecordCount)

ccw.PrintRecordCount (rs)

End Sub
VB.NET CLASS LIBRARY

Public Class Class1
Public Function PrintRecordCount(ByVal rs As ADODB.Recordset)

MsgBox("In VB.Net Class, about to display RecordCount... ")
[[[[START OF ERROR LINE]]]]
MsgBox("In VB.Net Class, rs.RecordCount = " & rs.RecordCount)
[[[[END OF ERROR LINE]]]]

End Function
End Class

(I also tried changing the type of the input parameter to
ADODB.RecordsetClass but the same error resulted.)

Jul 21 '05 #1
0 1886

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4965
by: Fredrik/Sweden | last post by:
Hi folks ! got this problem... i have a table 'Accounts' in my database, which contains a bunch of users. From the main menu i choose "edit user" and all users in the db are presented in a table....
0
1886
by: Johan Lachonius | last post by:
Hi, I'm using a "classic" asp-page and a .net-component which I want to call passing a Recordset as a parameter. I have a reference to ADODB in the .net component which should supply a COM...
0
386
by: adam | last post by:
I am getting an error when trying to use an ADODB.Recordset that was passed from a VB6 application to a VB.Net class library using COM Interop. I am running this on WinXP SP2 using the .Net...
27
6163
by: Oscar | last post by:
I am looking for a way to pass an ADO recordset that has been retrieved in an ASP page to another HTML-page. Is there someone who can provide me with a small sample or a link to see how this is...
0
2918
by: Phill | last post by:
Is there a simple way to pass a parameter to an ADO recordset instead of using a hard coded where statement like below(something like forms!aaa!fieldname). I've done a fair bit of searching but...
3
8068
by: whatduck | last post by:
I'm having trouble passing a variable that contains spaces. If the variable contains a space I get the following error: "Application uses a value of the wrong type for the current operation." ...
0
2277
by: Dot Netizen | last post by:
I am having trouble passing an ADODB.Recordset from a VB6 application to a VB.Net class library using COM Interop. I am running this on XP SP2 with the .Net Framework 1.1 and MDAC 2.8 SP1. I've...
0
1870
by: thisis | last post by:
Hi All, I'm getting an error on my ASP page: Microsoft VBScript runtime error '800a000d' Type mismatch: 'StoreFileIntoField' I assume - 99.5% - the error is generated because of worng...
0
1393
by: =?Utf-8?B?UmFodnlu?= | last post by:
I am working on a COM dll in C# that needs to pass an ADODB recordset back to the calling VBScript. I believe I have everthing setup correctly, as the calls work, and it looks like a recordset is...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.