Solved

COM Interop problem

Posted on 2003-11-28
4
654 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now