Database Management Review for Final (Part 1) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Wednesday 4/30/2003)

Slides:



Advertisements
Similar presentations
Basics of Database Programming with VB6
Advertisements

Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Fundamentals of Programming in Visual Basic
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
Input Dialog Box An input dialog box can be used to obtain a single item of input from the user Presents a window (dialog box) requesting input Syntax:
Fundamentals of Programming in Visual Basic
The ADO Data Control. Universal Data Access Open Database Connectivity (ODBC) –standard for accessing data in databases OLE-DB –allows access to data.
VB Built-in Functions School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 5, Monday 2/10/03)
The Initial Visual Basic Screen
Built-In Functions.
Visual Basic Database Access BICS546. Microsoft Universal Data Access OLE DB: The OLE database protocol –Allows a program to access information in any.
Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab10 Interacting with Data (Database Management)
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance.
Component 8, Slide 1 CP2030 Visual basic for C++ Programmers, ‘The VB Team’ Copyright © University of Wolverhampton CP2030 Visual Basic For C++ Programmers.
Fundamentals of Programming in Visual Basic
On to… string operations & functions. Concatenation (&) §When we want to combine two character strings into one new (longer) string, we can concatenate.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Chapter 8 Relational Databases ActiveX Database Controls 8 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Programming Practice in Visual Basic The Initial Visual Basic Screen Toolbox Project Explorer window Properties window Form Menu bar Description pane.
Fundamentals of Programming in Visual Basic
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
05/09/ Introducing Visual Basic Sequence Programming.
Handling of data from multiple databases. Visual Basic Database Visual Basic application acts as a front-end to the database Visual Basic application.
Copyright © 2001 by Wiley. All rights reserved. Chapter 10: Advanced Database Operations Revising Vintage Videos Setting RecordSource at run time DBGrid.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Tutorial 11 Using and Writing Visual Basic for Applications Code
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Interacting with Databases Chapter 10. VB and Databases u It is often useful to have a VB program access data stored in a file other than a text file.
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 11 Accessing Database.
Review for Exam 2 School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 10, Friday 3/21/2003) - IF Blocks - Do Loops - Select.
Using the selection structure (Unit 7) Visual Basic for Applications.
Working with Numeric Variables (Unit 6) Visual Basic for Applications.
Numeric Variables Visual Basic for Applications 6.
Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database.
Database Management School of Business Eastern Illinois University © Abdou Illia, Fall 2002 (Week 16, Monday 12/09/2002)
VBA Lab 2 I ns.Samia Al-blwi. Visual Basic Grammar Object: Visual Basic is an object-oriented language. This means that all the items in Excel are thought.
Database Applications – Microsoft Access Lesson 3 Creating and Modifying Forms and Reports Updated 09/13 35 slides in presentation.
Sub procedures School of Business Eastern Illinois University © Abdou Illia, Spring 2002 (Week 6, Friday 2/21/03)
IReport Demo Spring 2008 OEDSA Conference. Report Properties.
1 E0001 Computers in Engineering Built in Functions.
ActiveX Data Objects (ADO) is Microsoft’s latest database object model. The goal of ADO is to allow VB developers to use a standard set of objects to refer.
Tutorial 91 Databases A database is an organized collection of related information stored in a file on a disk A database allows companies to store information.
Chapter 8 - Visual Basic Schneider
Sequential files School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 12, Monday 4/07/2003)
Introduction to Programming Fundamentals of Programming in Visual Basic.
VB Objects & Events (Exercises) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 3, Friday 1/31/2003)
Tutorial 101 Variable Arrays A group of variables that have the same name and data type and are related in some way Can have as many as 60 dimensions.
Review for Final (Part 2) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Friday 5/2/2003)
Advanced Repetition Structure and String Functions (Unit 10) Visual Basic for Applications.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
HNDIT Rapid Application Development
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 6: Accessing a database with PHP Rob Gleasure robgleasure.com.
Using a Database Access97 Please use speaker notes for additional information!
1 ADO Activex Data Objects. 2 ADO ADO allows users to access data easily from many existing databases (such as Access or Paradox) From ODBC compliant.
1 VB-06-String Manipulation Mar 03, 2002 String Function VISUAL BASIC.
Generating XML Data from a Database Eugenia Fernandez IUPUI.
Chapter 3 - Visual Basic Schneider. Private Sub cmdEvaluate_Click() Dim n As Single, root As Single n = 6.76 root = Sqr(n) picResults.Print root; Int(n);
Visual Basic Database Access
The Recordset Object.
Database vs. DBMS Database Database Management System
5. Using databases in VB.
Fundamentals of Programming in Visual Basic
VISUAL BASIC INTRODUCTION TO DATA CONNECTIVITY.
Prepared By: Deborah Becker
Working With Databases
Introduction to Programming
Presentation transcript:

Database Management Review for Final (Part 1) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Wednesday 4/30/2003)

2 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)

3 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

4 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.

5 DAO control n Common properties: – DatabaseName Used to set the name and location of database – RecordSource Used to set specific table in the database – EOF End of File – BOF Beginning of File – RecordCount Number of records Examples: Name: datBiblio DatabaseSource: C:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB RecordSource: Titles

6 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

7 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

8 ADO control: Methods n Common methods used: – MoveFirst Move to the 1 st record and make it the current record – MoveLast Move to the last record and make it the current record – MoveNext Move to the next record and make it the current record – MovePrevious Move to the previous record and make it the current record – Recordset Used to refer to the content of the table in RecordSource n Recordset.Fields(“FieldName") n Recordset.Fields(" FieldName").Value n Example: datBiblio.Recordset.MoveLast ' Needed to set the value of RecordCount datBiblio.Recordset.MoveFirst For i = 0 To datBiblio.Recordset.RecordCount datBiblio.Recordset.MoveNext Next i

9 ADO control: Examples n Example 1 : If EOF is reached, move to the previous record If datBiblio.Recordset.EOF datBiblio.Recordset.MovePrevious End If n Example 2 : Delete the current record datBiblio.Recordset.Delete n Example 3 : Use datBiblio to add items do a list box To be done in class

Review For Final (Part 1)

Setting properties, Assignment statements

12 Statements for setting properties n General rule: ObjectNane.Property = Value Where ObjectName is the name of the Object Property is one of the properties of the object Value is a valid setting for Property Such statements are called Assignment statements

13 Setting colors n At design time – Colors are selected from the palette (in Properties Win.) n When writing code – 8 most common colors can be assigned with the following color constants: vbBlackvbRedvbGreenvbYellow vbBluevbMagnetavbCyanvbWhite Example: txtBox.ForeColor = vbGreen

14 Assigning Font settings n At design time – Font settings are assigned from the palette (in Properties Win.) n When writing code – Font settings can be assigned using statements like: txtBox.Font.Name = “Courier” txtBox.Font.Name = “Arial” txtBox.Font.Size = 18 lblOne.Font.Italic = True

15 Exercises n Exercises 19-32, page 68 Write a line (or lines) of code to carry out the following: n Display “The stuff that dreams are made of.” in red letters in txtBox txtBox.ForeColor = vbRed txtBox.Text = “The stuff that dreams are made of.” n Display “Life is like a box of chocolates.” in Courier font in txtBox txtBox.Text = “Life is like a box of chocolates.” txtBox.Font.Name = “Courier”

16 Exercises n Delete the content of txtBox txtBox.Text = “” n Delete the content of lblTwo lblTwo.Caption = “”

17 Exercises n Make lblTwo disappear lblTwo.Visible = False n Remove the border from lblTwo lblTwo.BorderStyle = 0 n Give picBox a blue background picBox.BackColor = vbBlue

18 Exercises n Place a bold red “Hello” in lblTwo lblTwo.Font.Bold = True lblTwo.ForeColor = vbRed lblTwo.Text = “Hello”

19 Exercises n Place a bold italic “Hello” in txtBox txtBox.Font.Bold = True txtBox.Font.Italic = True txtBox.Caption = “Hello” n Make picBox disappear picBox.Visible = False

20 Exercises n Give the focus to cmdButtom cmdButton.SetFocus n Remove the border from picBox picBox.BorderStyle = 0

21 Exercises n Place a border arround lblTwo and center its content lblTwo.BorderStyle = 1 lblTwo.Alignment = 2 n Give the focus to txtBoxTwo txtBoxTwo.SetFocus

Built-in Functions

23 Numeric Functions

24 Numeric Functions n Examples Sqr (9) is 3Int(2.7) is 2Round(2.7) is 3 Sqr (0) is 0Int(3) is 3 Round(2.317,2) is 2.32 Sqr (2) is Int(-2.7) is -3 Round(2.317,1) is 2.3 Private Sub cmdEvaluate_Click() Dim n As Single, root As Single ' Evaluate functions at a variable picResults.Cls n = 6.76 root = Sqr(n) picResults.Print root; Int(n); Round(n, 1) End Sub

25 String Functions Left (“String”, n) Returns a string containing a specified number of characters, starting at the beginning of the “String”. Right (“String”, n) Returns a string containing a specified number of characters from the end of the “String”. Mid (“String”, m, n) Returns a string containing a specified number of characters starting at the position indicated by the first number and continuing for the length specified by the second number UCase (“String”) Converts any lowercase letters in string to uppercase LCase (“String”) Converts any uppercase letters in string to lowercase InStr (“Str1”, ”Str2“) Searches for the first occurrence of one string in another and gives the position at which the string is found Len (“String”) Returns the number of characters in the string. Trim (“ String ”) Returns “String” with leading and trailing spaces removed.

26 String Functions n Examples Left (“fanatic”, 3) is “fan”Right (“fanatic”, 3) is “tic” Mid (“fanatic”,5,1) is “t” UCase(“Disk”) is “DISK”LCase(“Disk”) is “disk” Trim(“-12 “) is “-12”

27 Format Function n The format functions provide detailed control of how numbers, dates, and strings are displayed. n Example: FormatNumber ( , 1) 12,345.6 FormatCurrency ( , 2) $12, FormatPercent (.185, 2) 18.50% FormatNumber (1 + Sqr(2), 3) FormatDateTime(“ ”, vbLongDate) Wednesday, September 15, 1999 Format( , Format(FormatNumber(1234.5), 1,234.50

28 Exercises n 1. Given the data in the string variable y shown below, which of the following statements will assign the value ALL to the string variable x? y = "WHEN ALL ELSE FAILS, READ THE DIRECTIONS“ (A)x = Mid(y, 6, 3) (B)x = Left(y, 3) (C)x = Middle(y, 6, 3) (D)x = Right(y, 8)

29 Exercises n 2. What will be displayed when the following program is executed? Dim a As String, b As String, c As String a = "THE WHOLE" b = "PART" c = Mid(a, Sqr(4), Len(b)) picBox.Print c (A)THE WHOLE PART (B)6 (C)HE W (D)HOLE (E)None of the above

30 Exercises n 3.What will be the output of the following statement? picBox.Print FormatCurrency( ,2) (A)$ (B)1, (C)$ (D)$1,234.57

31 Exercises n 4. What will be the output of the following lines? Dim alphabet As String, soup As String alphabet = "abcdefghijklmnopqrstuvwxyz" soup = UCase(alphabet) picBox.Print Left(alphabet, 5); Left(soup, 5) (A)abcdeABCDE (B)ABCDEABCDE (C)eE (D)EE

32 Exercises n 5. What output is generated by the following statements (show the output EXACTLY as it would appear)? (A)picBox.Print Sqr(3^2 + 4^2) (B)picBox.Print Mid("Milkshake", 5, 5) (C)picBox.Print UCase("123jump")