3

I have an issue with ParamArray. This is supposed to be OPTIONAL by default but it seems it is not so.

I have the following code in an ASP page.

dim oUtil, sSQL, oRs, bCARS

Set oUtil = server.CreateObject("CPUtility.Feature")
sSql = "select CARSFlag from Version"
set oRs = oUtil.Execute("", sSql)

Then in my COM class I have the following definition

Public Function Execute(ByVal oDBConnection As Object, ByVal sSQL As String, ByVal ParamArray avParameters() As Object) As ADODB.Recordset

This result in an error where Execute method is not found/supported. But if I modify the Execute method in the ASP page to pass something to the ParamArray then it works just fine.

dim oUtil, sSQL, oRs, bCARS

Set oUtil = server.CreateObject("CPUtility.Feature")
sSql = "select CARSFlag from Version WHERE dbLanguage=? AND UtilityUpgrade=?"
set oRs = oUtil.Execute("", sSql, _
    Array("lang", adVarchar, adParamInput, 1, "E"), _
    Array("bit", adBoolean, adParamInput, 0, 1))

I don't understand why omitting the ParamArray parameter would result in the method not found/supported.

This is using .NET 4.6.2 and the class is registered in the GAC using GACUTIL and all entries have been added to the registry using REGASM

Jerome
  • 31
  • 1
  • When using the last snippet of code in your ASP, what is the value of the param array received by the COM object? Is it really an array containing two arrays? Or does the COM object receive only the first array as its ParamArray argument? – Michael Gunter Aug 15 '17 at 17:31
  • It is an array containing 2 arrays. If I display avParameters.Count then I get the value of 2. – Jerome Aug 15 '17 at 18:51
  • According to [this](https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/parameter-arrays), you can specify `Nothing` for the param array argument to produce a call without arguments. Have you tried that? – Michael Gunter Aug 15 '17 at 18:54
  • One thing I would be curious to see -- the IDL for the type library produced by VB.NET. Do you know how to extract the IDL? – Michael Gunter Aug 15 '17 at 18:56
  • Yes I tried with nothing or empty array, it doesn't work. I do not know how to extract the IDL. It seems it might be a registry issue since I was able to create another class that had the same functionality and was able able to make it work. – Jerome Aug 15 '17 at 19:15

0 Answers0