Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab10 Interacting with Data (Database Management)

Similar presentations


Presentation on theme: "Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab10 Interacting with Data (Database Management)"— Presentation transcript:

1 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab10 Interacting with Data (Database Management)

2 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 2 Database Concept Database: An integrated collection of data. Table: One data file (Set of records). Dbase: Collection of tables. Record: Set of fields. Field: Set of characters. Index: A key field with unique values for every record.

3 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 3 Flat-File (Table) Row - Record Fields - Columns Database Concept …[CONT]

4 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 4 Relational Database: Collection of tables in which no duplicate data is found. Database file Extension: FileName.MDB Ms-Database(MDB) Contents: –Tables –Reports –Forms –Queries Database Concept …[CONT]

5 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 5 Creating New Database Visual Data Manager: A program available with in the VB environment used to create databases. V.Data Manager Tasks: –Create a new database. –Enter A new data into data file. –Edit existing dbase. –Searching.

6 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 6 Executing Visual Data Manager 1- From Add-Ins menu select Visual Data Manager. 2- Visual Data Window appears. Visual Data Window

7 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 7 Creating Database 1- File menu => New => Microsoft Access => version 7.0 MDB. 2- Save the new database in the dialog box that appears. 3- The DataBase window will appear: Database format ( MsAccess,Dbase, FxPro …)

8 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 8 4- Select Properties. Right Click the mouse. Choose New Table.

9 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 9 Creating Database …. [CONT] 5- Add Table Name. Add the Fields & Indexes. Build the Table.

10 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 10 Using the Database You can add, update, delete data from the database as follow: Open the Dbase in the Database window. Open the table ( Double click or Right click to the mouse). Add, Update, Delete data. Close to return to the database window.

11 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 11 Data Control The data control enables you to access the database. Add data control to the form. Specify the following properties: –Database name –Record source –Caption.

12 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 12 Linking Dbase fields with form’s Controls Choose Label or Textbox control Change the following properties: –Data source (the data control name) –Data field. ( table field name )

13 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 13 Advanced Data Control Usage Data Control Methods: MoveFirst, MoveLast, MoveNaxt, MovePrevious, AddNew, Delete. Using Data Control Methods: Syntax DatacontrolName. Recordset.Method Example: Data1.RecordSet.AddNew

14 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 14 Data Control Properties Data1.Recordset.EOF return True when reach the end of the file (table) Data1.Recordset.BOF return True when reach the beginning of the file (table) Data1.Recordset.Fields(“fieldname”).value returns the value of the field

15 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 15 ADO Data Control Data Grid Control ADO stands for: ActiveX Data Object ADO data control : Enables accessing the database by VB program. Data Grid Control: Display in a table format the data requested form the database.

16 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 16 Adding ADO & Data Grid Controls to the ToolBox From the project menu select components (CTRL T) From the dialog box select: –Microsoft ADO Data control 6.0. –Microsoft DatGrid Control 6.0. Click Ok button. Now you can see two new controls appears at the end of the tool box.

17 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 17 Designing ADO Control Add the ADO control to the form. Change the following properties: Connection String: –Provider : Microsoft jet 3.51 OLE DB Provider. –Select Dbase name. –Test Connections. Record Source: –Command Type: 2-adcmdTable. –Table: TableName –Apply

18 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 18 Designing Data Grid Control Add Data Grid control to the form. Change the following properties: Data Source: Specify the ADO Name. Right Click the mouse. Select Retrieve Fields. From properties window assign the access type to the database ( Add, Delete….).

19 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 19 Data Grid Control Properties AllowAddNew (True/False): Enables to add new records. AllowUpdate(True/False): Enables to update records. AllowDelete(True/False): Enables to delete a specified record.

20 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 20 Data Grid Control Properties Col: (Column number): Enables you to specify a column. Row( Row Number): enables you to specify a row. Text: The text in the specified cell from Row&Col. Example: Datagrid1.Row=0: Datagrid1.Col=0 Print Datagrid1.text

21 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 21 Lab Training Using the MDI, design the following interface

22 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 22 Lab Training [CONT]

23 Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 23 Lab10End


Download ppt "Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab10 Interacting with Data (Database Management)"

Similar presentations


Ads by Google