How to use the K2 ADO.NET Data Provider SerialNumber Parameter
KB000191
PRODUCT
Introduction |
The ADO.NET provider plays an integral role in the K2 platform. It provides developers with many levels of customization options, at both the process and user interaction levels. |
Note: This document assumes some programming knowledge and familiarity with ASP.NET and the K2 API. |
Using the Serial Number Parameter
When using the ADO.NET provider to list the Actions from a Worklist item surfaced in an ASP.NET page, a Serial Number parameter is used for identification purposes.
An error will be returned if the developer adds a parameter called SerialNumber in order to list all the Actions corresponding to a specific Serial Number. The SQL data source already has a parameter named SerialNumber. The second declared SerialNumber parameter has a null value, therefore no values will be returned.
The following code demonstrates this condition:
Parameter param = new Parameter("SerialNumber", TypeCode.String, SN);
soSqlLoad.SelectParameters.Add(param);
DataView dv = (DataView)soSqlLoad.Select(DataSourceSelectArguments.Empty); //would return null
As the SQL data source already contains the SerialNumber parameter, adding another parameter is unnecessary. Instead the SerialNumber parameter of the SQL data source can be loaded with the required Serial Number and used to return the corresponding Worklist Actions.
Example
soSqlLoad.SelectParameters["SerialNumber"].DefaultValue = SN;
DataView dv = (DataView)soSqlLoad.Select(DataSourceSelectArguments.Empty);
In this example, the serial number is retrieved from the ASP.NET request and then used to set the SerialNumber parameter of the SQL query.