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

Unit 10: Database Fundamentals and Connectivity Option



                  • Put an ADO Data Control on form, and set the properties as follows:

                                               Property            Value
                                 Name                    adoBiblio
                                 DataSourceName          Biblio

                                 SQL                     select * from authors

                  • Now put three text boxes on the form, and set their Name, DataSource, and DataField
                    properties as follows:

                                 Name            DataSource       DataField

                                 txtAuthor       adoBiblio        Author
                                 txtAuID         adoBiblio        Au_ID

                                 txtYearBorn     adoBiblio        Year Born

                  • Save and run the program. Notice how it works just like the other data control.

                  • Now change the SQL property of the data control to select * from authors order by author
                    and run the program again. Notice the difference.
                  • Change the SQL property back to what it was and add three command buttons to the form,
                    and set their Name and Caption properties as follows:

                                           Name                  Caption

                                   cmdNameOrder           Order by  Name
                                   cmdYearOrder           Order by  Year
                                   cmdIDOrder             Order by  ID


                  • Put the following code in the  cmdNameOrder_Click event: adoBiblio.SQL = “select * from
                    authors order by author” adoBiblio.Refresh
                  • Put the following code in the  cmdYearOrder_Click event: adoBiblio.SQL = “select * from
                    authors order by [year born]” adoBiblio.Refresh

                  • Put the following code in the  cmdIDOrder_Click  event: adoBiblio.SQL = “select * from
                    authors order by au_id” adoBiblio.Refresh

                  • Save and run the program and see what happens when we click the buttons.











                                      LOVELY PROFESSIONAL UNIVERSITY                        231
   232   233   234   235   236   237   238   239   240   241   242