Set qd = db.CreateQueryDef("TestQd", "Parameters IdSearch1 Long, IdSearch2 Long, CostSearch1 IEEEDouble, CostSearch2 IEEEDouble; Update testtable Set Cost = Cost *.9 where cost > CostSearch1 and cost < CostSearch2 and id >= IdSearch1 and id < IdSearch2")
qd.Close
'Start the clock
TimeStart = GetTickCount()
BeginTrans
'Open the querydef
Set qd = db.OpenQueryDef("TestQd")
'Set the paramter values
qd!IdSearch1 = 5000
qd!IdSearch2 = 6000
qd!CostSearch1 = 30
qd!CostSearch2 = 40
'Execute the querydef
qd.Execute
CommitTrans
'Stop the clock and report
TimeCount = GetTickCount() - TimeStart
Text1(4) = Format$(TimeCount / 1000, "##0.00")
'Remove the querydef - normally we wouldn't do this
Set qd = db.CreateQueryDef("TestQd", "Parameters IDSearch1 Long, IDSearch2 Long; Select * From Testtable where id >= IDSearch1 and Id < IdSearch2 and Id \ 2 = Id / 2")
qd.Close
'Start the clock
TimeStart = GetTickCount()
For foo = 1 To 10
'Open the querydef
Set qd = db.OpenQueryDef("TestQd")
'Set the paramter values
qd!IdSearch1 = 5000
qd!IdSearch2 = 5100
'Build the dynaset from the querydef
dyna.Close
'Note the required alternate syntax!
Set dyna = qd.CreateDynaset()
Do Until dyna.EOF
dyna.MoveNext
Loop
'Close the querydef
qd.Close
Next foo
'Stop the clock and report
TimeCount = GetTickCount() - TimeStart
Text1(4) = Format$(TimeCount / 1000, "##0.00")
'Remove the QueryDef
db.DeleteQueryDef ("TestQd")
CloseDb
'Populate the DB Test Set ============================================
Case 2
Me.Caption = "VBench: Populate Database"
'Initialize costs so we'll have a nice variety
cost(1) = 19.95
cost(2) = 29.95
cost(3) = 39.95
cost(4) = 49.95
cost(5) = 9.95
'Use transactions for speed
BeginTrans
OpenDb
db.Execute "Delete * from TestTable"
For foo = 1 To 10000
foobar = foobar + 1
If foobar > 5 Then foobar = 1
tbl.AddNew
tbl!cost = cost(foobar)
tbl!id = foo
tbl.Update
Next foo
CommitTrans
CloseDb
'Exit the program ====================================================