VBScript Return RecordSet Problem

In my VBScript code, I tried to return a result set and put ot into an array, however, error "Microsoft VBScript runtime error: Wrong number of arguments or invalid property assignment", a piece of code is as below:

Sub DBConnect()
        Dim sConnect

        On Error Resume Next
        Set g_cnnMBDM = CreateObject("ADODB.Connection")

        sConnect = "Provider=SQLOLEDB"
        sConnect = sConnect & ";Trusted_Connection=yes"
        sConnect = sConnect & ";Server=" & g_sMBDM_SVR
        sConnect = sConnect & ";Database=" & g_sWORK_DB

        g_cnnMBDM.CommandTimeout = g_sMBDM_TIMEOUT
        g_cnnMBDM.Open sConnect

        If Err <> 0 Then WriteError("Error in DBConnect: " & Err.Description) : CleanUp() : Exit Sub
End Sub

Sub GetCurrentDateCubeParameter()

        Dim sSQL, adoRecordSet
      Dim CubeParameter
      Dim i, j
      'Get MM Profile cube parameter for current date
      sSQL = "lis_mm_profile_cube_parameter_ct"

      Set adoRecordSet = g_cnnMBDM.Execute(sSQL)
        If adoRecordSet.EOF Then
                g_bError = False
                Call WriteError("No Parameter found for mm_profile_cube generation!"): Exit Sub
                CubeParameter = adoRecordSet
         i = UBound(CubeParameter,1)
         j = UBound(CubeParameter,2)
        End If

End Sub
Who is Participating?
confabberConnect With a Mentor Commented:
This would help u understand better

Change ur code like this:

        sConnect = "Provider=SQLOLEDB"
        sConnect = sConnect & ";Trusted_Connection=yes"
        sConnect = sConnect & ";Data Source=" & g_sMBDM_SVR
        sConnect = sConnect & ";Initial Catalog=" & g_sWORK_DB

Replace "Server" with "Data Source"
and "Database" with "Initial Catalog"
acwngAuthor Commented:
The code runs to the line "i = UBound(CubeParameter,1)" then aborted with the same error "Microsoft VBScript runtime error: Wrong number of arguments or invalid property assignment"
Any clue?
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

UBound Works on Arrays and not on recordsets
have you defined "g_cnnMBDM" variable as a public variable?

as what we can find in your source code, you creat your database connection in a subrutine and fetch the required data into a recordset in another one using the connection that you have created before, this connection variable should be defined as a public variable to be accessable in both subrutines
acwngAuthor Commented:
so how to put the recordset into array format?

Yes, it is a global variable.
acwngAuthor Commented:
My goal is to return the resultset of the return values of the stored procedure "lis_mm_profile_cube_parameter_ct" into an array format. That's all.
what did your record set returns? in other word you should know the dimention of the matrix that it would return the fill up the array nodes one by one - instead of working with array I sugget you to work with recordset directly, there are several properties and method available for a record set that facilitates all what you need to do with.
you can get access to each filed using its item no or their related labels, you can navigate the recordset on all records reaching nextrecord, previous, last or the first record and so on..
acwngAuthor Commented:
confabber, you're about right. After I lop thru the result set array, the array is the other way around, i.e. "the rows become the column" and "the column become the rows".
Hoew to make the array inverted?
Dim iRowLoop, iColLoop
For iRowLoop = 0 to UBound(aTable1Values, 2)
  For iColLoop = 0 to UBound(aTable1Values, 1)
    Response.Write(aTable1Values(iColLoop, iRowLoop) & "<br>")
  Next 'iColLoop

Next 'iRowLoop

Not too sure what u mean by "rows become column and column becomes rows"

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.