CreateRecordset 方法 (RDS)CreateRecordset Method (RDS)

创建一个空的、断开连接的 记录集Creates an empty, disconnected Recordset.


从 Windows 8 和 Windows Server 2012 开始,Windows 操作系统中不再包含 RDS 服务器组件 (参阅 Windows 8 和 Windows Server 2012 兼容性指南 ,以了解更多详细信息) 。Beginning with Windows 8 and Windows Server 2012, RDS server components are no longer included in the Windows operating system (see Windows 8 and Windows Server 2012 Compatibility Cookbook for more detail). 在 Windows 的未来版本中将删除 RDS 客户端组件。RDS client components will be removed in a future version of Windows. 请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。Avoid using this feature in new development work, and plan to modify applications that currently use this feature. 使用 RDS 的应用程序应迁移到 WCF 数据服务Applications that use RDS should migrate to WCF Data Service.




一个对象变量,它表示 RDSServerRDS。DataControl 对象。An object variable that represents an RDSServer.DataFactory or RDS.DataControl object.

特性的一个 变量 数组,用于定义创建的 记录集中 的每一列。A Variant array of attributes that defines each column in the Recordset created. 每个列定义都包含一个包含四个必需属性和一个可选属性的数组。Each column definition contains an array of four required attributes and one optional attribute.

特性Attribute 说明Description
名称Name 列标题的名称。Name of the column header.
类型Type 数据类型的整数。Integer of the data type.
大小Size 字符宽度的整数,与数据类型无关。Integer of the width in characters, regardless of data type.
可空性Nullability 布尔值。Boolean value.
缩放 (可选) Scale (Optional) 此可选特性定义数值字段的小数位数。This optional attribute defines the scale for numeric fields. 如果未指定此值,数值将被截断为三个小数位数。If this value is not specified, numeric values will be truncated to a scale of three. 精度不受影响,但小数点后的位数将被截断为三。Precision is not affected, but the number of digits following the decimal point will be truncated to three.

然后,将列数组集分组到一个数组中,该数组定义 记录集The set of column arrays is then grouped into an array, which defines the Recordset.


服务器端业务对象可以使用非 OLE DB 的数据访问接口中的数据(例如包含股票行情的操作系统文件)来填充生成的 记录集The server-side business object can populate the resulting Recordset with data from a non-OLE DB data provider, such as an operating system file containing stock quotes.

下表列出了 CreateRecordset 方法支持的 DataTypeEnum值。The following table lists the DataTypeEnum values supported by the CreateRecordset method. 列出的数字是用于定义字段的引用编号。The number listed is the reference number used to define fields.

每个数据类型均为固定长度或可变长度。Each of the data types is either fixed length or variable length. 应将固定长度类型定义为-1,因为大小是预先确定的,并且仍需要大小定义。Fixed-length types should be defined with a size of -1, because the size is predetermined and a size definition is still required. 可变长度数据类型允许从1到32767的大小。Variable-length data types allow a size from 1 to 32767.

对于某些可变数据类型,可以将类型强制转换为替换列中所述的类型。For some of the variable data types, the type can be coerced to the type noted in the Substitution column. 在创建并填充 记录集 之前,你将看不到替换项。You will not see the substitutions until after the Recordset is created and filled. 如果需要,可以检查实际数据类型。Then you can check for the actual data type, if necessary.

长度Length 返回的常量Constant 数字Number 替换Substitution
固定Fixed adTinyIntadTinyInt 1616
固定Fixed adSmallIntadSmallInt 22
固定Fixed adIntegeradInteger 33
固定Fixed adBigIntadBigInt 2020
固定Fixed adUnsignedTinyIntadUnsignedTinyInt 1717
固定Fixed adUnsignedSmallIntadUnsignedSmallInt 1818
固定Fixed adUnsignedIntadUnsignedInt 1919
固定Fixed adUnsignedBigIntadUnsignedBigInt 2121
固定Fixed adSingleadSingle 44
固定Fixed adDoubleadDouble 55
固定Fixed adCurrencyadCurrency 66
固定Fixed adDecimaladDecimal 1414
固定Fixed adNumericadNumeric 131131
固定Fixed adBooleanadBoolean 1111
固定Fixed adErroradError 1010
固定Fixed adGuidadGuid 7272
固定Fixed adDateadDate 77
固定Fixed adDBDateadDBDate 133133
固定Fixed adDBTimeadDBTime 134134
固定Fixed adDBTimestampadDBTimestamp 135135 77
变量Variable adBSTRadBSTR 88 130130
变量Variable adCharadChar 129129 200200
变量Variable adVarCharadVarChar 200200
变量Variable adLongVarCharadLongVarChar 201201 200200
变量Variable adWCharadWChar 130130
变量Variable adVarWCharadVarWChar 202202 130130
变量Variable adLongVarWCharadLongVarWChar 203203 130130
变量Variable adBinaryadBinary 128128
变量Variable adVarBinaryadVarBinary 204204
变量Variable adLongVarBinaryadLongVarBinary 205205 204204

应用于Applies To

另请参阅See Also

CreateRecordset 方法示例 (VB) CreateRecordset Method Example (VB)
CreateRecordset 方法示例 (VBScript) CreateRecordset Method Example (VBScript)
CreateObject 方法 (RDS)CreateObject Method (RDS)