WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADO DAO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ado_seek


;Winbatch 2005C - Using ADO Seek with Winbatch Array
;
;Seek() versus Find() - Find only works on a single field
;                       whereas seek works with expressions
;
;NOTE: This script uses the Northwind Database which ships with
;      Microsoft Office
;
;Stan Littlefield - September 13, 2005
;////////////////////////////////////////////////////////////////

;ADO Constants
adOpenForwardOnly = 0
adOpenKeyset = 1
adOpenDynamic = 2
adOpenStatic = 3

adLockReadOnly = 1
adLockPessimistic = 2
adLockOptimistic = 3
adLockBatchOptimistic = 4

adCmdUnknown = 8
adCmdText = 1
adCmdTable = 2
adCmdStoredProc = 4
adCmdFile = 256
adCmdTableDirect = 512


adUseServer = 2

adSeekFirstEQ = 1
adSeekLastEQ = 2
adSeekAfterEQ = 4
adSeekAfter = 8
adSeekBeforeEQ = 16


cMDB=StrCat(DirScript(),"NorthWind.mdb")
cConn = "Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=%cMDB%"
oRS = CreateObject("ADODB.Recordset")

;3 elements to using seek()
;appropriate index must be set, use server cursor, use adCmdTableDirect
oRS.Index = "PrimaryKey"
oRS.CursorLocation = adUseServer
oRS.Open("Order Details",cConn,adOpenKeyset,adLockOptimistic,adCmdTableDirect)

;set up Winbatch Array
aAr = ArrDimension(2)
aAr[0] = 10255
aAr[1] = 16
cSeek = "OrderId = 10255 and ProductId = 16"
; array simulates cSeek
oRS.Seek(aAr,adSeekFirstEQ)

If ! oRS.eof
   Display(3,StrCat("Order Quantity for ",cSeek),oRS.Fields("Quantity").Value)
Else
   Display(3,"Order Quantity","Seek Failed!")
EndIf
oRS.Close()
oRS=0
Exit

Article ID:   W17108
File Created: 2007:07:03:14:28:20
Last Updated: 2007:07:03:14:28:20