Solved

COM Interop problem

Posted on 2003-11-28
4
674 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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