Microsoft KB Archive/319140

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

Article ID: 319140

Article Last Modified on 5/26/2004

-

APPLIES TO


 * Microsoft Commerce Server 2002 Standard Edition

-



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 &quot;0x779da69a&quot; referenced memory at &quot;0x00bbf000&quot;. The memory could not be &quot;read&quot;.

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 &quot;Symptoms&quot; section occurs. The following sample causes the access violation error that is mentioned in the &quot;Symptoms&quot; section: Dim vOrderFormArray(0) Dim SQLWhere SQLWhere = SQLWhere & &quot;Order_Number > 0 &quot; vOrderFormArray(0) = SQLWhere 'Notice: vOrderForArray here is an array. Set oOrderGroupManager = CreateObject(&quot;Commerce.OrderGroupManager&quot;) oOrderGroupManager.Initialize &quot;Provider=SQLOLEDB.1;User ID=sa;Password= ;Initial Catalog=;Data Source= ;Network Library=dbmssocn;&quot; 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 & &quot;Order_number > 0&quot; vOrderFormArray = Array(SQLWhere)  'Notice: vOrderFormArray here is a variant. You can compare this sample with the previous sample.

Set oOrderGroupManager = CreateObject(&quot;Commerce.OrderGroupManager&quot;) oOrderGroupManager.Initialize &quot;Provider=SQLOLEDB.1;User ID=sa;Password= ;Initial Catalog=;Data Source= ;Network Library=dbmssocn;&quot; Set oSFResult = oOrderGroupManager.Find(obj, vOrderFormArray, obj) Set oOrderGroupManager = Nothing Set oSFResult = Nothing

Keywords: kbinfo kbbug kbfix kbfile kbprb kbdocerr KB319140

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.