The getSize and setSize methods of the Parameter class indicate or set, respectively, the maximum size, in bytes or characters, of a Parameter object.
public int getSize();
public void setSize(int s);
Sets or returns a value that indicates the maximum size in bytes or characters of a value in a Parameter object.
s | A value that indicates the maximum size in bytes or characters of a value in a Parameter object. |
Use getSize to determine the maximum size for values written to or read from the Parameter object. The size value is read/write.
If you specify a variable-length data type for a Parameter object (for example, any String type), you must set the object's size before appending it to the Parameters collection; otherwise an error occurs.
If you have already appended the Parameter object to the Parameters collection of a Command object and you change its type to a variable-length data type, you must set the Parameter object's size before executing the Command object; otherwise an error occurs.
If you use the refresh method to obtain parameter information from the provider and it returns one or more variable-length data type Parameter objects, ADO may allocate memory for the parameters based on their maximum potential size, which could cause an error during execution. To prevent an error, you should explicitly set the size for these parameters before executing the command.