Creates a new parameter object with the specified property.
Syntax
Set parameter = command. createparameter (name, type, direction, size, value)
For example
Cm. Parameters. append cm. createparameter ("bh", 3, 1, 10, rqid)
Return Value
Returns the parameter object.
Parameters
Name
Optional. String value, including the name of the parameter object.
Type
Optional. Datatypeenum value, which specifies the Data Type of the parameter object.
Direction
Optional. Parameterdirectionenum value, which specifies the parameter object type.
Size
Optional. Long value, which specifies the maximum length (in characters or bytes) of the parameter value ).
Value
Optional. Variant, which specifies the value of the parameter object.
Description
Use the createparameter method to create a new parameter object with the specified name, type, direction, size, and value. Any value transmitted in the parameter will be written to the corresponding parameter attribute.
This method does not automatically append a parameter object to the parameters set of the command object. In this way, you can set additional attributes. When you append a parameter object to a set, ADO will make the values of these additional attributes take effect.
If you specify a variable-length data type in the type parameter, you must transmit the size parameter or set the size attribute of the parameter object before appending it to the parameters set. Otherwise, an error occurs.
If you specify the numeric data type (adnumeric or addecimal) in the type parameter, you must also set the numericscale and precision attributes.
Related attributes
Type attribute
InstructionsParameter,FieldOrPropertyThe operation type or data type of the object.Set and return values
Set or return the followingDatatypeenumValue. The corresponding ole db type identifier is given in brackets in the description column of the following table. For more information about the ole db data type, see Appendix A in Chapter 10th and the ole db programmer reference.
Constant |
Description |
Adarray |
Join logic with other typesOrTo indicate that the data is a type of security array (dbtype_array ). |
Adbigint |
An 8-byte signed integer (dbtype_i8 ). |
Adbinary |
Binary value (dbtype_bytes ). |
Adboolean |
Boolean value (dbtype_bool ). |
Adbyref |
Join logic with other typesOrTo indicate that the data is a pointer to other types of data (dbtype_byref ). |
Adbstr |
String ending with an empty string (UNICODE) (dbtype_bstr ). |
Adchar |
StringValue (dbtype_str ). |
Adcurrency |
Currency value (dbtype_cy ). The decimal point is fixed, and there are four digits on the right of the decimal point. This value is saved as a signed integer value with an 8-byte range of 10,000. |
Addate |
DateValue (dbtype_date ). The date is saved as a double-precision value. All the numbers indicate the number of days that have elapsed since January 1, December 30, 1899. The fractional part is the part time in a day. |
Addbdate |
Date value (Yyyymmdd) (Dbtype_dbdate ). |
Addbtime |
Time Value (Hhmmss) (Dbtype_dbtime ). |
Addbtimestamp |
Timestamp (YyyymmddhhmmssAdd a decimal point of one of 1 billion points) (dbtype_dbtimestamp ). |
Addecimal |
Exact numeric value with fixed precision and range (dbtype_decimal ). |
Addouble |
Double-precision floating point value (dbtype_r8 ). |
Adempty |
The value (dbtype_empty) is not specified ). |
Aderror |
32-bit error code (dbtype_error ). |
Adguid |
Globally Unique Identifier (guid) (dbtype_guid ). |
Adidispatch |
On the OLE objectIdispatchInterface pointer (dbtype_idispatch ). |
Adinteger |
4-byte signed integer (dbtype_i4 ). |
Adiunknown |
On the OLE objectIunknownInterface pointer (dbtype_iunknown ). |
Adlongvarbinary |
Long binary value (used onlyParameterObject ). |
Adlongvarchar |
LongStringValue (used onlyParameterObject ). |
Adlongvarwchar |
Long string value ending with an empty string (used onlyParameterObject ). |
Adnumeric |
Precise numeric value with fixed precision and range (dbtype_numeric ). |
Adsingle |
Single precision floating point value (dbtype_r4 ). |
Adsmallint |
2-byte signed integer (dbtype_i2 ). |
Adtinyint |
1-byte signed integer (dbtype_i1 ). |
Adunsignedbigint |
8-byte unsigned integer (dbtype_ui8 ). |
Adunsignedint |
4-byte unsigned integer (dbtype_ui4 ). |
Adunsignedsmallint |
2 bytes of unsigned integer (dbtype_ui2 ). |
Adunsignedtinyint |
1 byte unsigned integer (dbtype_ui1 ). |
Aduserdefined |
User-Defined variable (dbtype_udt ). |
Advarbinary |
Binary value (onlyParameterObject ). |
Advarchar |
StringValue (onlyParameterObject ). |
Advariant |
AutomaticShaping(Dbtype_variant ). |
Advector |
Join logic with other typesOrIndicates that the data is a dbvector structure (defined by ole db ). This structure contains the counting of elements and pointers of other data types (dbtype_vector. |
Advarwchar |
Unicode string ending with an empty string (onlyParameterObject ). |
Adwchar |
A Unicode string (dbtype_wstr) ending with an empty string ). |
DescriptionPair
ParameterObject,
TypeThe attribute is read/write. For all other objects,
TypeThe attribute is read-only.
Direction attributes
Indicates whether the parameter indicates the input parameter, output parameter, or input parameter, or whether the parameter is the value returned by the stored procedure.
Set and return values
Sets or returns the following parameterdirectionenum value.
Constant |
Description |
Adparamunknown |
The parameter direction is unknown. |
Adparaminput |
Default value. Indicates the input parameters. |
Adparamoutput |
Indicates the output parameters. |
Adparaminputoutput |
Both the input and output parameters are indicated. |
Adparamreturnvalue |
Indicates the return value. |
Description
The direction attribute can be used to transmit parameters to or from a targeted process. The direction attribute is read/write. This attribute allows providers that do not return this information, or you can set this information when you do not want ADO to call the provider to obtain the parameter information.
Not all providers can determine the parameter direction in their stored procedures. In this case, you must set the direction Attribute before executing the query.
Size attribute
The maximum size of a parameter object, in bytes or characters ).
Set and return values
Sets or returns the long integer value that represents the maximum size (by byte or character) of the parameter object.
Description
Use the size attribute to determine the maximum size of the Value Attribute written (or read) value of the parameter object. The size attribute is readable/written.
If you want to specify a parameter object as a variable-length data type (such as any string type, such as advarchar), you must first set the size attribute of the object and then append the object to the parameters set. Otherwise, an error occurs.
If you have appended a parameter object to the parameter set of the command object and changed its type to variable-length data type, you must set the size attribute of the parameter object 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 space to the object based on its maximum possible size, this may cause errors during execution. To avoid errors, you should explicitly set the size attribute of these parameters before executing the command.