Page 253 - Open Soource Technologies 304.indd
P. 253

Unit 11: Data Base Access



                  5. This adds the DataGrid, DataCombo, and DataList control tools to the toolbox; draw those
                    controls as you want them on your form.
               Here are the principal data properties you use with these three controls:
                  • DataGrid—DataSource  = ADO data control’s name. You can also set the  AllowAddNew,
                    AllowDelete, AllowUpdate properties to True or False to enable or disable those operations.
                  • DataCombo—DataSource  = ADO data control’s name;  DataField  = Name of the field to
                    display in the combo’s text box; ListField = Name of field to display in the list; RowSource
                    = ADO data control’s name; and BoundColumn = Name of the source field with which you
                    can provide data to another control.
                  • DataList—DataSource = ADO data control’s name; DataField = Name of the field to display
                    in the current selection, ListField = Name of field to display in the list, RowSource = ADO
                    data control’s name, BoundColumn = Name of the source field with which you can provide
                    data to another control.
               Let’s see an example. In this case, we’ve added an ADO data control and the three ADO data-
               bound controls to a program, as shown in Figure 11.1, and connected them to the ADO data
               control using their various properties. The code for this example is to locate in the dbcontrols2
               folder on this book’s accompanying CD-ROM.
































                                     Figure 11.1: Using the ADO Bound Controls.


                              Error Event Procedure Code Not a Replacement for Your Own Error Handlers
                              the ADO Data Control’s Error event does not free you from writing error
                              handlers in your own data manipulation code! The Error event handles errors
                              that are not caused by your code. You still must handle the runtime errors
                              generated by your code.




                                      LOVELY PROFESSIONAL UNIVERSITY                        247
   248   249   250   251   252   253   254   255   256   257   258