Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBScript Return RecordSet Problem

Posted on 2004-08-22
10
Medium Priority
?
1,116 Views
Last Modified: 2012-08-13
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
        Else
                CubeParameter = adoRecordSet
         i = UBound(CubeParameter,1)
         j = UBound(CubeParameter,2)
        End If

End Sub
0
Comment
Question by:acwng
[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
  • 4
  • 4
  • 2
10 Comments
 
LVL 1

Expert Comment

by:confabber
ID: 11867404
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"
0
 
LVL 1

Author Comment

by:acwng
ID: 11867510
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?
0
 
LVL 1

Expert Comment

by:confabber
ID: 11867683
UBound Works on Arrays and not on recordsets
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:NoshadAhmadi
ID: 11867816
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
0
 
LVL 1

Author Comment

by:acwng
ID: 11867849
confabber,
so how to put the recordset into array format?

NoshadAhmadi,
Yes, it is a global variable.
0
 
LVL 1

Accepted Solution

by:
confabber earned 200 total points
ID: 11867887
This would help u understand better

http://www.aspfaqs.com/ASPScripts/PrintFAQ.asp?FAQID=161
0
 
LVL 1

Author Comment

by:acwng
ID: 11867897
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.
0
 

Expert Comment

by:NoshadAhmadi
ID: 11867898
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..
0
 
LVL 1

Author Comment

by:acwng
ID: 11867980
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?
0
 
LVL 1

Expert Comment

by:confabber
ID: 11868168
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

  Response.Write("<p>")
Next 'iRowLoop

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

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is about my first experience with programming Arduino.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Six Sigma Control Plans

636 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