473,624 Members | 2,515 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 PrintRecordCoun t below. Instead, I get the
following error:

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

Any ideas?
VB6 APP

Private Sub Command1_Click( )

Dim ccw As New VBNETClass.Clas s1

Dim rs As New ADODB.Recordset
Set rs = CreateObject("A DODB.Recordset" )
rs.CursorType = adOpenStatic
rs.CursorLocati on = adUseClient
rs.Fields.Appen d "FieldName1 ", adVarChar, 10
rs.Fields.Appen d "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.PrintRecord Count (rs)

End Sub
VB.NET CLASS LIBRARY

Public Class Class1
Public Function PrintRecordCoun t(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.Recordset Class but the same error resulted.)

Jul 21 '05 #1
0 1897

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

Similar topics

3
4976
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. The first column 'Pnr' is a unique ID for each user that i made appear as a link. clicking on one userID should present a form where the picked users userdata is already filled in so i can easily edit it and then move on to submit the form to...
0
1900
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 rapper for a Recordset. In the .net component code looks like: using ADODB: public void MyFunction( Recordset rs )
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 Framework 1.1 and MDAC 2.8 SP1. This is what I've done: - I 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. - I...
27
6186
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 done? regards, Oscar
0
2932
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 can not seem to come up with a way to provide this in a simple manner. I have done this using pass through queries and stored procedures (as a form based search method)but I guess I am just experimenting to see if the below is a more efficient way...
3
8098
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." If I pass a variable with out any spaces the procedure executes without error. I have a procedure on SQL Server 2000 with the following variable: Create Procedure Zproc_Demand_Matrix
0
2278
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 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...
0
1881
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 value types, I attemp to pass from my ASP/VBScript page to the VB/DLL function.
0
1404
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 returned, however, the recordset is null or closed. What is the trick to passing a recordset back from C#? The Call: Set rs = CreateObject("Interface") rs.Init "System", "ODBC", "user", "pass", "database", "server" retVal =...
0
8231
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8614
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8471
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7153
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6107
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.