Solved

VBScript Return RecordSet Problem

Posted on 2004-08-22
10
1,102 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
Technology Partners: 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!

 

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 50 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change the background and font colors in Notepad++ 5 158
Help Required 2 46
ASP/VB email question 4 63
How to call a web service and get the results posted in a form in PHP 9 79
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

730 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