An access violation may occur if you pass an array parameter directly to the OrderGroupManager.Find method (319140)



The information in this article applies to:

  • Microsoft Commerce Server 2002

This article was previously published under Q319140

SYMPTOMS

In Microsoft Commerce Server 2002, if you use the Find method of the OrderGroupManager object, and you pass an array parameter instead of a variant parameter, an access violation may occur. You may receive an error message that is similar to one or both of the following:
Unhandled exception at 0x779da52a in cscript.exe: 0xC0000005: Access violation reading location 0x00bbb000.
The instruction at "0x779da69a" referenced memory at "0x00bbf000". The memory could not be "read".
Click OK to terminate the program
Click CANCEL to debug the program

CAUSE

This problem occurs when you try to pass an array parameter, instead of a variant parameter that points to an array, to the Find method.

MORE INFORMATION

The Commerce Server 2002 documentation states that the OrderGroupManager.Find method requires three parameters that are defined as variants. The other parameters are optional. If you pass an array parameter instead of a variant parameter to the OrderGroupManager.Find method, the expected result is a type mismatch error, but an access violation occurs. In Microsoft Visual Basic Scripting Edition, Dim vOrderFormArray(0) declares an array. The vOrderFormArray = Array(SQLWhere) array function returns a variant that contains an array. If a vOrderFormArray(0) array parameter is passed to the OrderGroupManager.Find method, the access violation error that is mentioned in the "Symptoms" section occurs. The following sample causes the access violation error that is mentioned in the "Symptoms" section:
    Dim vOrderFormArray(0)
    Dim SQLWhere
    SQLWhere = SQLWhere & "Order_Number > 0 "
    vOrderFormArray(0) = SQLWhere  'Notice: vOrderForArray here is an array.
  
    Set oOrderGroupManager = CreateObject("Commerce.OrderGroupManager")
    
    oOrderGroupManager.Initialize "Provider=SQLOLEDB.1;User ID=sa;Password=<your sa password>;Initial Catalog=<your runtime transaction database>;Data Source=<your server data source>;Network Library=dbmssocn;"
    
    Set oSFResult = oOrderGroupManager.Find(vOrderGroupArray, vOrderFormArray, vLineItemArray)

    Set oOrderGroupManager = Nothing
    Set oSFResult = Nothing
The correct way to use the OrderGroupManager.Find method is to use the vOrderFormArray=Array(SQLWhere) array function, and then pass the vOrderFormArray variant from the array function to the OrderGroupManager.Find method. The following sample uses the array function that returns a variant. This sample is the correct way to call the OrderGroupManager.Find method:
    Dim vOrderFormArray
    Dim SQLWhere   
    SQLWhere = SQLWhere & "Order_number > 0"
    vOrderFormArray = Array(SQLWhere)   'Notice: vOrderFormArray here is a variant. You can compare this sample with the previous sample.

    Set oOrderGroupManager = CreateObject("Commerce.OrderGroupManager")
    
    oOrderGroupManager.Initialize "Provider=SQLOLEDB.1;User ID=sa;Password=<your sa password>;Initial Catalog=<your runtime transaction database>;Data Source=<your server data source>;Network Library=dbmssocn;"
    
   Set oSFResult = oOrderGroupManager.Find(obj, vOrderFormArray, obj)
   
   Set oOrderGroupManager = Nothing
   Set oSFResult = Nothing

Modification Type:MajorLast Reviewed:5/26/2004
Keywords:kbdocerr kbfix kbinfo kbfile kbprb kbbug KB319140 kbAudDeveloper