JoeIngle
asked on
COM Interop problem
Guys
I'm getting an unusual error when trying to pass an adodb.recordset between to .vb files. The first file is wrapper for some old asp pages. It's calling a function in a data access assembly. It should be returning a recordset that in turn is returned to the calling asp page.
The error I'm getting is:
Microsoft.VisualBasic error '80020007'
No named arguments.
Never seen this before, and besides, i should have to use named arguments!
Calling ASP code:
Set objInt = Server.CreateObject("Inter opServer.I nteropServ er")
Set Return2 = objInt.ReturnRecordset2("P r_InteropT est","5")
Return2.Open
Do While Not Return2.EOF
Response.Write Trim(Return2.Fields(0).Val ue & "") & ", " & Trim(Return2.Fields(1).Val ue & "") & "<br>"
Return2.MoveNext
Loop
Wrapper code:
Public Function ReturnRecordset2(ByVal p_strSQL As String, ByVal p_strRole As String) As ADODB.Recordset
Dim objRS As New ADODB.Recordset()
Dim Role As String
Role = p_strRole
Select Case Role
Case 1
DalRequest.Role = DalRequest.RoleObject.DOTN ETOpen
Case 2
DalRequest.Role = DalRequest.RoleObject.DOTN ETSecure
Case 3
DalRequest.Role = DalRequest.RoleObject.DOTN ETLog
Case 4
DalRequest.Role = DalRequest.RoleObject.ADOO pen
Case 5
DalRequest.Role = DalRequest.RoleObject.ADOS ecure
Case 6
DalRequest.Role = DalRequest.RoleObject.ADOL og
End Select
Dim DataProvider As AbstractProvider = DALFactory.GetProvider(Pro viderType. Sql, DalRequest.Role)
DalRequest.Command = p_strSQL
objRS = DataProvider.ExecuteADO()
Return objRS
End Function
Data Access Code:
Public Overloads Overrides Function ExecuteADO() As ADODB.Recordset
Dim objConADO As New ADODB.Connection()
Dim p_objConsumer As New ADODB.Recordset()
objConADO.Open(ConnectionS tring)
Try
p_objConsumer.Open(DalRequ est.Comman d, objConADO)
Catch e As SqlException
Throw e
Finally
':: Disconnect the recordset
objConADO.ActiveConnection = Nothing
':: Close connection
objConADO.Close()
End Try
':: Return recordset
Return p_objConsumer
End Function
I should point out that that both the wrapper and the data access assembly are registered for COM Interop. When I run SQL trace I can see that the code is getting as far as executing the stored procedure (p_objConsumer.Open(DalReq uest.Comma nd, objConADO)) above.
Any help would be greatly appreciated.
TIA
Joe
I'm getting an unusual error when trying to pass an adodb.recordset between to .vb files. The first file is wrapper for some old asp pages. It's calling a function in a data access assembly. It should be returning a recordset that in turn is returned to the calling asp page.
The error I'm getting is:
Microsoft.VisualBasic error '80020007'
No named arguments.
Never seen this before, and besides, i should have to use named arguments!
Calling ASP code:
Set objInt = Server.CreateObject("Inter
Set Return2 = objInt.ReturnRecordset2("P
Return2.Open
Do While Not Return2.EOF
Response.Write Trim(Return2.Fields(0).Val
Return2.MoveNext
Loop
Wrapper code:
Public Function ReturnRecordset2(ByVal p_strSQL As String, ByVal p_strRole As String) As ADODB.Recordset
Dim objRS As New ADODB.Recordset()
Dim Role As String
Role = p_strRole
Select Case Role
Case 1
DalRequest.Role = DalRequest.RoleObject.DOTN
Case 2
DalRequest.Role = DalRequest.RoleObject.DOTN
Case 3
DalRequest.Role = DalRequest.RoleObject.DOTN
Case 4
DalRequest.Role = DalRequest.RoleObject.ADOO
Case 5
DalRequest.Role = DalRequest.RoleObject.ADOS
Case 6
DalRequest.Role = DalRequest.RoleObject.ADOL
End Select
Dim DataProvider As AbstractProvider = DALFactory.GetProvider(Pro
DalRequest.Command = p_strSQL
objRS = DataProvider.ExecuteADO()
Return objRS
End Function
Data Access Code:
Public Overloads Overrides Function ExecuteADO() As ADODB.Recordset
Dim objConADO As New ADODB.Connection()
Dim p_objConsumer As New ADODB.Recordset()
objConADO.Open(ConnectionS
Try
p_objConsumer.Open(DalRequ
Catch e As SqlException
Throw e
Finally
':: Disconnect the recordset
objConADO.ActiveConnection
':: Close connection
objConADO.Close()
End Try
':: Return recordset
Return p_objConsumer
End Function
I should point out that that both the wrapper and the data access assembly are registered for COM Interop. When I run SQL trace I can see that the code is getting as far as executing the stored procedure (p_objConsumer.Open(DalReq
Any help would be greatly appreciated.
TIA
Joe
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry, new to the site. What is PAQ and Community Supports?
Joe
Joe
Search through the list of Topic Areas at https://www.experts-exchange.com/allTopics.jsp, and find the one that says 'Community Support'. Post a question in this area asking for this question to be deleted. (P)reviously (A)sked (Q)uestion means that this question has important information, even if the expert wasn't able to help you.
ASKER
With p_objConsumer
.ActiveConnection = objConADO
':: Note: CursorLocation should be set to adUseServer by default.
.CursorLocation = adUseServer
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockBatchOptimistic
.Open(DalRequest.Command, , adOpenStatic, adLockBatchOptimistic)
':: Disconnect the recordset.
.ActiveConnection = Nothing
End With
Ta