Page 262 - Open Soource Technologies 304.indd
P. 262
Event Driven Programming
1. How to Create an ADO Data Control?
11.8 Self Assessment Questions
1. You can set the contents of an ADO Recordset field named ID with the following code:
(a) sClients.ID.Value = strID
(b) rsClients.Fields(ID).Value = strID
(c) rsClients!Fields!(ID).Value = strID
(d) rsClients!ID = strID
2. The ADO Errors collection
(a) Clears before every ADO action.
(b) Contains a history of all errors during this session.
(c) Contains the last errors generated by an ADO action.
(d) Contains a lookup list of all possible ADO error codes.
3. Which code would appropriately display ADO errors (connNwind is an ADO Connection
and rsEmployees is an ADO Recordset object)?
(a) Dim adoErr As ADODB.Error For Each adoErr In connNWind.Errors MsgBox
adoErr.Description Next /
(b) Dim adoErr As ADODB.Error For Each adoErr In rsEmployees.Errors MsgBox
adoErr.Description Next adoErr
(c) Dim adoErr As ADODB.Error For Each adoErr In connNWind MsgBox
connNWind.Error.Description Next adoErr
(d) Dim adoErr As Error For Each adoErr In connNWind.Errors MsgBox adoErr.Description
Next adoErr
4. You write the following code to search for a record in an ADO Recordset: Dim sFindCriterion
As String s FindCriterion = “LastName like ‘“ & _txtLastNameToFind & “‘“
rsEmployees.MoveFirst rsEmployees.Find sFindCriterion To test whether a record was
encountered, you should write the following code:
(a) If rsEmployees.NoMatch Then
(b) If rsEmployee.EOF Then
(c) If rsEmployee.BookMark = 0 Then
(d) If rsEmployee.BookMark = rsRmployee.RecordCount Then
256 LOVELY PROFESSIONAL UNIVERSITY