Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Management School of Business Eastern Illinois University © Abdou Illia, Fall 2002 (Week 16, Monday 12/09/2002)

Similar presentations


Presentation on theme: "Database Management School of Business Eastern Illinois University © Abdou Illia, Fall 2002 (Week 16, Monday 12/09/2002)"— Presentation transcript:

1 Database Management School of Business Eastern Illinois University © Abdou Illia, Fall 2002 (Week 16, Monday 12/09/2002)

2 2 Exam 3 n Answers to Exam questions will be presented

3 3 Quiz 2 n Answers to Quiz questions will be presented

4 4 Friday’s class Exercise 1 n Suppose that a form contains (1) a list box named lstNumbers containing positive numbers, (2) a command button named cmdDisplay, (3) and a picture box named picOutput. Write a click event procedure associated to the command button. The procedure should calculate the total and the average of the numbers in the list, and display the average in the picture box. Private Sub cmdDisplay_Click () Total = 0 For i = 0 To lstNumbers.ListCount -1 Total = Total + val(lstNumbers.List(i)) Next i AVG = Total / lstNumbers.ListCount picOutput.Print “The average is :”; AVG End Sub

5 5 Friday’s class Exercise 2 n Suppose that the list box lstEmployee is as shown. Write the statements that store its items in the file Employee.txt. Open lstEmployee.txt For Output As #1 For i = 0 To lstEmployee.ListCount -1 Write #1, lstEmployee.List(i) Next i Close #1

6 6 What is a Database ? n Database: Collection of information stored in tables n Example: BIBLIO.MDB Au_IDAuthorYear Born Authors Table (6246 Records, 3 Fields) PubID Name Company Fax Comments Publishers Table (727 Records, 10 Fields) Au_ID ISBN Title Author Table (16056 Records, 2 Fields)

7 7 Table, Field, Record Authors Table Au_ID Author Year_Born A001 Jacobs, Russell 1945 A002 Metzger, Philip W. 1961A003 Sydow, Dan Parks 1948: : :: : : Field Record

8 8 VB and Database Management n Two tools in VB 6.0 to manage databases – Activex Data Object (ADO) – Data Access Object (DAO) n ADO control should be added to the toolbox (Project/Components and check Microsoft ADO Data Control) n ADO and DAO controls can be used to: – Connect to a database. – Open a specified database table. – Create a virtual table based on a database query. – Pass database fields to other Visual Basic tools, for display or editing. Such tools are bound tools (controls), or data aware. – Add new records or update a database.

9 9 DAO control n Common properties: – DatabaseName Used to set the name and location of database – RecordSource Used to set specific table in the database Examples: Name: datBiblio DatabaseSource: C:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB RecordSource: Titles

10 10 Bounding Text boxes to DAO control n Text boxes are said data-aware because they can be bound to DAO controls and access their data n Two Text boxes properties are used to bound them to DAO controls: – DataSourceUsed to set the DAO control from which data is read – DataField Used to set the field of the table from which data is read Examples: Name: txtTitle DataSource: datBiblio DataField: Title Name: TxtYear DataSource: datBiblio DataField: Year_Published

11 11 Exercise n Create the following user-interface with one DAO control and two text boxes so that data in the table Titles from the database BIBLIO.MDB (found in the main VB directory). Name: txtTitle DataSource: datBiblio DataField: Title Name: TxtYear DataSource: datBiblio DataField: Year_Published Name: datBiblio DatabaseSource: C:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB RecordSource: Titles


Download ppt "Database Management School of Business Eastern Illinois University © Abdou Illia, Fall 2002 (Week 16, Monday 12/09/2002)"

Similar presentations


Ads by Google