Ok, this has completely stumped me. Here's the deal.
I have a VB6 DLL that I have registered as a COM, and have also created a .NET wrapper for using tlbimp.exe. I have also included a wrapper for msado15.dll, the ADO 2.7 Microsoft DLL containing the ADODB._Recordset and ADODB._Record references. Additionally, that is the EXACT (and only) DLL I am referencing in VB6 and using for my recordets. Here is the code:
VB6 Component:
Public Function Query_DB(DB_DSN as String, Table as String, ParamString as String, Optional OrderBy as String, Optional OrderDirection as String, Optional FieldName as String) as Variant
Dim cnnDB as New ADODB.Connection
Dim rsDB as New ADODB.Recordset
Dim strSQL as String
cnnDB.Open "DSN=" & DB_DSN
strSQL = "Select * from [" & Table & "] " & ParamString
If Len(OrderBy)>0 Then
strSQL = strSQL & " Order By [" & OrderBy & "]"
If UCase(OrderDirection) = "ASC" Or UCase(OrderDirection) = "DESC" Then
strSQL = strSQL & " " & OrderDirection
End if
End If
Set rsDB = cnnDB.Execute(strSQL)
If Len(FieldName)>0 Then
Query_DB = CStr(rsDB(FieldName))
Else
Set Query_DB = rsDB
End if
Set rsDB = Nothing
cnnDB.Close
Set cnnDB = Nothing
End Function
As you can see, it simply returns either the value of a specified field, or the whole recordset. The coding itself has worked before, I am now trying to use it with .NET.
Here is how I'm calling it in ASPX:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Ole
Db" %>
<%@ Import Namespace="netIASET" %>
<%@ Import Namespace="ADODB" %>
<%@ Page Language="vb" Debug="true" %>
<%@ Register TagPrefix="Macromedia" Namespace="FlashGateway" Assembly="flashgateway" %>
<Macromedia:Flash id="Flash" Runat="Server" />
Dim objIADB as IADB
objIADB = new IADB()
Dim rsGroups as ADODB._Recordset = objIADB.Query_DB("MAIN","G
ROUPS","",
"GroupID",
"Asc","")
Dim daGroups as OleDbDataAdapter = New OleDbDataAdapter
Dim dsGroups as DataSet = New DataSet
daGroups.Fill(dsGroups,rsG
roups,"Gro
ups")
'assign the dataset into Macromedia Flash flash.datasource property
Flash.DataSource = dsGroups.Tables("Groups")
'bind datatable to flash
Flash.DataBind()
Don't worry about the Macromedia Flash stuff, that's me using Flash Remoting, it doesn't even come into effect yet. IADB is the Class in which the previous Function exists. Now, I can create the object fine, and if I just return a fieldvalue (a string) I get it just fine. However, when I try to return a recordset I get: SPECIFIED CAST IS NOT VALID. I researched it and found it to be a mismatch in DLLs, but I am using the same exact DLL in VB6 as in the aspx file. I am just completely stumped. PLEASE HELP.
Btw, ADODB.dll is the msado15.dll file installed with ADO 2.7 put thru tlbimp.exe (as recommended by Microsoft in Filling an ADO RecordSet with a DataSet). And netIASET.dll is the wrapper for my VB6 component.
HELP HELP HELP! I want to give more then 500, and will do so if someone finds an answer. I was thinking 1000.
kfblake