473,626 Members | 3,237 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing a Recordset from VB6 to VB.Net (QueryInterface failed.)

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 added references to the ADO 2.8 Library from both the VB6 app and the
VB.Net library. (I also tried ADO 2.6 and 2.7 later but they had the same
results.)
- I built the VB6 EXE and copied it to the directory containing the VB.Net
DLL.

When I run the VB6 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...")
' this line works
MsgBox ("In VB6 Class, rs.RecordCount = " & rs.RecordCount)

ccw.PrintRecord Count (rs)

End Sub

VB.NET CLASS LIBRARY (VBNETClass)

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

MsgBox("In VB.Net Class, about to display RecordCount... ")
' this line produces the error
MsgBox("In VB.Net Class, rs.RecordCount = " & rs.RecordCount)

End Function
End Class

(I also tried changing the type of the input parameter to
ADODB.Recordset Class and ADODB._Recordse t but the same error resulted.)

Nov 22 '05 #1
0 1497

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

Similar topics

0
417
by: Jason | last post by:
I'm writing a small console app in .NET that needs to reference a 3rd party dll. I wrote the app by adding a reference to the 3rd party dll in my project and my code builds and executes perfectly. However, when I made a setup file and installed it on another box, I get: System.InvalidCastException: QueryInterface for interface...Failed. when the console app tires to reference the dll. I can see that the
0
1443
by: matt | last post by:
Hi There we have a new asp.net site that is getting a lot of hits. I have set this up on its own server with its own database server. We have a search system built into the site which is timing out (there are thousands of pages to full text search) I have got several of the following event logs which may be attributed to doing a search which times out EVENT ID 1090 SOURCE: ASP.NET 1.1.4322. Failed to execute request because...
0
1898
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
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
1242
by: Deeps | last post by:
Hi I have created an interface called IGlobal with some properties exposed with a fixed Guid. Created a class inherting this interface. This is my com+ server. I have a client instantiating this object with prog id. I made a build and installed the application, everything works fine. Now, I changed the interface to add one more property and implemented in the class. call it form my client. Rebuild. Now i get an exception...
0
1979
by: Mullin Yu | last post by:
hi, i got an error QueryInterface for interface DocMgr._clsDocMgr failed where DocMgr is a COM object written by VB6. I just compiled DocMgr with a changed revision but SAME classid (binary compatiblity is true). why do i get this error? will changing revision of a COM will generate this error? do i need to compile my program everytime i compiled DocMgr which is a common module. it seems not a good method.
4
4911
by: Ram | last post by:
I am running a test web site on my own Win2k professional computer. I have a VB6 COM component (running on COM+) on a seperate application runnint as "Server". When running an ASP.NET page calling this component, it works fine, but When I try and debug the Com+ process using the VB6.0 IDE, I get the following error: "Exception Details: System.InvalidCastException: QueryInterface for interface MyObject._MyCls failed." When I the same...
1
2368
by: Michael Connerton | last post by:
The company I work for still uses Excel97. In a weaker moment I added the pia for Excel2003 in attempt to get more programatic functionality out of some Excel interfaces I have been writing. The pia is entitled 'Microsoft.Office.Interop.Excel.dll' I also added the registry entries for that pia by running 'Microsoft.Office.Interop.Excel.dll.reg.' After performing that stunt the following code consistantly fails on the second line excelApp...
1
1323
by: adiel_g | last post by:
Hello, I have created a activeX dll in vb6 that contains some functions I am using in .NET. I created the dll in vb6 with: Instancing = 5-Multiuse MTSTransactionMode = 2-RequiresTransaction Persistable = 0-NotPersistable I then created a COM+ application, set the user to an admin in the COM+ settings and added the dll above as a component. Then from ASP.NET, I added a reference to the dll created above. Everything was fine (on my
0
8262
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
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8364
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
8502
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...
1
6122
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
4090
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...
1
2623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1507
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.