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

Event Driven Programming



                          13.7  Creating Various Type Data

                              • Once you have gone to all the trouble of developing and managing a database, it is nice
                                to have the ability to obtain printed or displayed information from your data. The process
                                of obtaining such information is known as creating a data report.
                          There are two steps to creating a data report. First, we need to create a Data Environment. This
                          is designed within Visual Basic and is used to tell the data report what is in the database. Second,
                          we create the Data Report itself. This, too, is done within Visual Basic. The Data Environment
                          and Data Report files then become part of the Visual Basic project developed as a database
                          management system.

                          The Visual Basic 6.0 data report capabilities are vast and using them is a detailed process. The
                          use of these capabilities is best demonstrated by example. We will look at the rudiments of report
                          creation by building a tabular report for our phone database.


                                        Phone Directory—Building a Data Report
                                        We will build a data report that lists all the names and phone numbers in our phone
                                        database. We will do this by first creating a Data Environment, then a Data Report.
                                        We will then reopen the phone database management project and add data reporting
                                        capabilities.


                          13.8  Creating a Data Environment Report Using Grid

                              1. Start a new  Standard  EXE project.
                              2. On the Project menu, click Add  Data  Environment. If this item is not on the menu, click
                                Components. Click the Designers tab, and choose Data Environment and click OK to add
                                the designer to your menu.
                              3. We need to point to our database. In the  Data  Environment window, right-click the
                                Connection1 tab and select  Properties. In the  Data  Link  Properties dialog box, choose
                                Microsoft Jet 3.51 OLE DB Provider. Click  Next to get to the  Connection tab. Click the
                                ellipsis button. Find your phone database (mdb) file. Click  OK to close the dialog box.
                              4. We now tell the  Data Environment what is in our database. Right-click the  Connection1
                                tab and click Rename. Change the name of the tab to Phone. Right-click this newly named
                                tab and click  Add Command  to create a  Command1 tab. Right-click this tab and choose
                                Properties. Assign the following properties:

                                Command Name—PhoneList
                                Connection—Phone
                                DataBase Object—Table
                                ObjectName—PhoneList

                              5. Click  OK. All this was needed just to connect the environment to our database.
                              6. Display the properties window and give the data environment a name property of
                                denPhone. Click  File and  Save denPhone As. Save the environment in an appropriate



                          284                    LOVELY PROFESSIONAL UNIVERSITY
   285   286   287   288   289   290   291   292   293   294   295