功能:將對象追加到集合中,如果集合是fields,可以先創建field對象然後再將其追加到集合中
格式:1.collection.append object
Collection:集合對象
Object:對象變量,代表所要追加的對象
例:
Dim objcmd as new command
Dim Parm as new Parameter
‘創建新的Parameter對象
Set Parm=objCmd.creadParameter(“用戶名”,adVarChar,adParamInput,10)
‘將Parm追加到Parameters集合中
Objcmd.Parameters.append Parm
2.fields.Appendname,type,definedsize,attrib
Name:字符串,新field對象名稱,不得與fields中的任何其它對象同名
Type:新字段的數據類型,其默認值爲adEmpty
Definedsize:可選,指示新字段定義大小,默認definedsize未指定
Attrib:可選,指定新字段屬性,默認值adflddefault
注:1.在調用fields.append方法前沒設置cursorlocation屬性,當使用open方法打開recordset時,cursorlocation將被自動設置爲aduseclient。2.對打開的recordset或已設置actionconnection屬性的recordset,調用fields.append方法將引發運行時錯誤
例:Dim objDataSource as new recordset
Dim obiRs as new recordset
Dim intrecord as integer
For intrecord=0 to objRs.fields.count-1
objDataSource.fields.append objRs.fields(intrecord).name,adVarChar,_
objRs.fields(intrecord).definedSize
Next ‘將記錄集的數據都追加到臨時記錄集的