Solved

COM Interop problem

Posted on 2003-11-28
4
663 Views
Last Modified: 2012-05-04
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("InteropServer.InteropServer")

Set Return2 = objInt.ReturnRecordset2("Pr_InteropTest","5")

Return2.Open

Do While Not Return2.EOF
            
    Response.Write Trim(Return2.Fields(0).Value & "") & ", " & Trim(Return2.Fields(1).Value & "") & "<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.DOTNETOpen
            Case 2
                DalRequest.Role = DalRequest.RoleObject.DOTNETSecure
            Case 3
                DalRequest.Role = DalRequest.RoleObject.DOTNETLog
            Case 4
                DalRequest.Role = DalRequest.RoleObject.ADOOpen
            Case 5
                DalRequest.Role = DalRequest.RoleObject.ADOSecure
            Case 6
                DalRequest.Role = DalRequest.RoleObject.ADOLog
        End Select

        Dim DataProvider As AbstractProvider = DALFactory.GetProvider(ProviderType.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(ConnectionString)

            Try

                p_objConsumer.Open(DalRequest.Command, 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(DalRequest.Command, objConADO)) above.

Any help would be greatly appreciated.

TIA

Joe

0
Comment
Question by:JoeIngle
  • 2
  • 2
4 Comments
 

Author Comment

by:JoeIngle
ID: 9838007
Problem solved!! With inclusion:

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
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 9849939
Please ask for this question to be PAQ with points refunded in Community Supports.  Thanks.
0
 

Author Comment

by:JoeIngle
ID: 9849996
Sorry, new to the site. What is  PAQ and Community Supports?

Joe
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9857738
Search through the list of Topic Areas at http://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.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question