473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.)

Nov 21 '05 #1
0 1016

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

Similar topics

3
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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
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,...

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.