Solved

COM Interop problem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

18 Experts available now in Live!

Get 1:1 Help Now