Solved

COM Interop problem

Posted on 2003-11-28
4
671 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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…

685 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