Parameters Collection
Parameter Object
Parameter Size Property
METHOD: Command::CreateParameter
Set
parameterobject
=
commandobject.
CreateParameter
(
Name, Type, Direction, Size, Value
)
The
CreateParameter
method returns a
Parameter
object containing the specified name, type, direction, size, and/or value properties.
Note: The
CreateParameter
method does not automatically add (append) the new
Parameter
to the collection. If you wish to add a new
Parameter
to the
Parameters Collection
, you need to use the
Append
property.
You can use
CreateParameter
without any parameters. You can later use the various appropriate properties of the
Parameter
object to add the name, type, direction, size and/or value.
There are five optional parameters.
The optional
Name
parameter is a string that is the name of the
Parameter
object.
The optional
Type
parameter is one of the
DataTypeEnum
constants that specifies the data type for the
Parameter
object. If you choose a variable-length data type, you will need to also provide the size using either the
Size
parameter or the
Size
property. If you do not provide the
Size
, an error will be generated when you attempt to append the
Parameter
to the
Parameters Collection
. The default is
adEmpty
.
If you specify an
adDecimal
or
adNumeric
data type, you will also have to set the
NumericScale
and the
Precision
properties of the
Parameter
object.
DataTypeEnum Constants
Constant
Value
Description
adArray
0x2000
Combine with another data type to indicate that the other data type is an array
adBigInt
20
8-byte signed integer
adBinary
128
Binary
adBoolean
11
True or false Boolean
adBSTR
8
Null-terminated character string
adChapter
136
4-byte chapter value for a child recordset
adChar
129
String
adCurrency
6
Currency format
adDate
7
Number of day since 12/30/1899
adDBDate
133
YYYYMMDD date format
adDBFileTime
137
Database file time
adDBTime
134
HHMMSS time format
adDBTimeStamp
135
YYYYMMDDHHMMSS date/time format
adDecimal
14
Number with fixed precision and scale
adDouble
5
Double precision floating-point
adEmpty
0
no value
adError
10
32-bit error code
adFileTime
64
Number of 100-nanosecond intervals since 1/1/1601
adGUID
72
Globally unique identifier
adIDispatch
9
Currently not supported by ADO
adInteger
3
4-byte signed integer
adIUnknown
13
Currently not supported by ADO
adLongVarBinary
205
Long binary value
adLongVarChar
201
Long string value
adLongVarWChar
203
Long Null-terminates string value
adNumeric
131
Number with fixed precision and scale
adPropVariant
138
PROPVARIANT automation
adSingle
4
Single-precision floating-point value
adSmallInt
2
2-byte signed integer
adTinyInt
16
1-byte signed integer
adUnsignedBigInt
21
8-byte unsigned integer
adUnsignedInt
19
4-byte unsigned integer
adUnsignedSmallInt
18
2-byte unsigned integer
adUnsignedTinyInt
17
1-byte unsigned integer
adUserDefined
132
User-defined variable
adVarBinary
204
Binary value
adVarChar
200
String
adVariant
12
Automation variant
adVarNumeric
139
Variable width exact numeric with signed scale
adVarWChar
202
Null-terminated Unicode character string
adWChar
130
Null-terminated Unicode character string
The optional
Direction
parameter is one of the
ParameterDirectionEnum
constants that defines the direction (input vs. output, etc.) of the
Parameter
object. The default is
adParamInput
.
ParameterDirectionEnum Constants
Constant
Value
Description
adParamInput
1
Input parameter
adParamInputOutput
3
Both input and output parameter
adParamOutput
2
Output parameter
adParamReturnValue
4
Return value
adParamUnknown
0
Direction is unknown
The optional
Size
parameter is a long value that specifies the length of a variable-length data type, if such a type was declared in the
Type
parameter. If you do not provide the
Size
for a variable-length data type, an error will be generated when you attempt to append the
Parameter
to the
Parameters Collection
. The default is zero.
The optional
Value
parameter is a variant that is the value of the
Parameter
.
Code (VBScript):
Set objParameter = objCommand.
CreateParameter
objParameter.Name = "ConfirmID"
objParameter.Type = adBoolean
objParameter.Direction = adParamInput
objParameter.Value = True
or
Set objParameter = objCommand.
CreateParameter
("ConfirmID", adBoolean, adParamInput, True)
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information