鍦≧ecordset瀵硅薄涓煡璇㈣褰曠殑鏂规硶
鍙戝竷: 2008-7-01 15:14 | 浣滆: admin | 鏌ョ湅: 50娆

鍦≧ecordset瀵硅薄涓煡璇㈣褰曠殑鏂规硶
鐑
銆愬瓧浣擄細灏 澶с
鍦≧ecordset瀵硅薄涓煡璇㈣褰曠殑鏂规硶
浣滆咃細- 鏂囩珷鏉ユ簮锛- 鐐瑰嚮鏁帮細756 鏇存柊鏃堕棿锛2006-12-13 
鏃犺鏄 DAO 杩樻槸 ADO 閮芥湁涓ょ浠 Recordset 瀵硅薄涓煡璇㈣褰曠殑鏂规硶锛 Find 鏂规硶鍜 Seek 鏂规硶銆傚湪杩欎袱绉嶆柟娉曚腑鍙互璁╀綘鎸囧畾鏉′欢杩涜鏌ヨ涓庡叾鐩稿簲鐨勮褰 , 涓鑸岃█锛屽湪鐩稿悓鏉′欢涓嬶紝 Seek 鏂规硶鎻愪緵浜嗘瘮 Find 鏂规硶鏇村ソ鐨勬ц兘锛屽洜涓 Seek 鏂规硶鏄熀浜庣储寮曠殑銆傚洜涓鸿繖涓師鍥犲熀鏈彁渚涜呭繀椤绘敮鎸 Recordset 瀵硅薄涓婄殑绱㈠紩锛屽彲浠ョ敤 Supports ( adSeek ) 鏂规硶纭畾鍩烘湰鎻愪緵鑰呮槸鍚︽敮鎸 Seek 锛岀敤 Supports ( adIndex ) 鏂规硶纭畾鎻愪緵鑰呮槸鍚︽敮鎸佺储寮曘傦紙渚嬪锛 OLE DB Provider for Microsoft Jet 鏀寔 Seek 鍜 Index 銆傦級锛岃灏 Seek 鏂规硶鍜 Index 灞炴х粨鍚堜娇鐢ㄣ傚鏋 Seek 娌℃湁鎵惧埌鎵闇鐨勮锛屽皢涓嶄細浜х敓閿欒锛岃琛屽皢琚斁鍦 Recordset 鐨勭粨灏惧銆傛墽琛屾鏂规硶鍓嶏紝璇峰厛灏 Index 灞炴ц缃负鎵闇鐨勭储寮曘傛鏂规硶鍙彈鏈嶅姟鍣ㄧ娓告爣鏀寔銆傚鏋 Recordset 瀵硅薄鐨 CursorLocation 灞炴у间负 adUseClient 锛屽皢涓嶆敮鎸 Seek 銆傚彧鏈夊綋 CommandTypeEnum 鍊间负 adCmdTableDirect 鏃舵墦寮 Recordset 瀵硅薄锛屾墠鍙互浣跨敤姝ゆ柟娉曘
鐢 ADO Find 鏂规硶
DAO 鍖呭惈浜嗗洓涓 Find 鈥濇柟娉曪細 FindFirst,FindLast,FindNext 鍜 FindPrevious .
DAO 鏂规硶 ADO Find 鏂规硶
涓嬮潰鐨勪竴涓緥瀛愮ず鑼冧簡濡備綍鐢 ADO Find 鏂规硶鏌ヨ璁板綍锛
Sub FindRecord(strDBPath As String, _
strTable As String, _
strCriteria As String, _
strDisplayField As String)
' This procedure finds a record in the specified table by
' using the specified criteria.
' For example, to use this procedure to find records
' in the Customers table in the Northwind database
' that have " USA " in the Country field, you can
' use a line of code like this:
' FindRecord _
' "c:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb", _
' "Customers", "Country=' USA '", "CustomerID"
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
' Open the Connection object.
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open strDBPath
End With
Set rst = New ADODB.Recordset
With rst
' Open the table by using a scrolling
' Recordset object.
.Open Source:=strTable, _
ActiveConnection:=cnn, _
CursorType:=adOpenKeyset, _
LockType:=adLockOptimistic
' Find the first record that meets the criteria.
.Find Criteria:=strCriteria, SearchDirection:=adSearchForward
' Make sure record was found (not at end of file).
If Not .EOF Then
' Print the first record and all remaining
' records that meet the criteria.
Do While Not .EOF
Debug.Print .Fields(strDisplayField).Value
' Skip the current record and find next match.
.Find Criteria:=strCriteria, SkipRecords:=1




发表于 2009-1-5 19:48
| 











