Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database.

Slides:



Advertisements
Similar presentations
Basics of Database Programming with VB6
Advertisements

 Open the Paradise.exe file  Application displays records in the Books database  Allows the store manager to enter an author’s name (or part of a name)
Chapter 8 Embedded SQL.
Chapter 12: Using ADO.NET 2.0 Programming with Microsoft Visual Basic 2005, Third Edition.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Using ADO.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab10 Interacting with Data (Database Management)
CIS 338: Using DAO (Data Access Objects) Dr. Ralph D. Westfall February, 2003.
Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance.
1 Chapter 8 Object-Based Programming in VBA. 8 Chapter Objectives Declare and use object variables Create procedures that use built-in form methods Find.
Component 8, Slide 1 CP2030 Visual basic for C++ Programmers, ‘The VB Team’ Copyright © University of Wolverhampton CP2030 Visual Basic For C++ Programmers.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Concepts of Database Management Sixth Edition
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Chapter 8 Relational Databases ActiveX Database Controls 8 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
LESSON 17 PREPARED BY MANJU. database A database is a collection of related information Access is the Microsoft Office database program that enables you.
Some Basic Database Terminology
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
9-1 Chapter 9 Working with Databases in VB.NET. 9-2 Learning Objectives Understand how databases are used to store business data and how they differ from.
Concepts of Database Management, Fifth Edition
Databases and LINQ Visual Basic 2010 How to Program 1.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
ASP.NET Programming with C# and SQL Server First Edition
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.
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.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Copyright © 2001 by Wiley. All rights reserved. Chapter 12: Programmer- Defined Types, Direct Access Files, and Object Classes Programmer Defined Data.
DAY 14: ACCESS CHAPTER 1 Tazin Afrin October 03,
Chapter 15: Using LINQ to Access Data in C# Programs.
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 11 Accessing Database.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
CHAPTER EIGHT Accessing Data Processing Databases.
Copyright © 2001 by Wiley. All rights reserved. Chapter 5: The Repetition Process in Visual Basic Event Driven Loops Determinate Loops Indeterminate Loops.
CHAPTER EIGHT Accessing Data Processing Databases.
File Processing Concepts – Field – combination of 1 or more characters that is the smallest unit of data to be accessed – Record – group of related fields.
Lecture Note 10: Simple Database Techniques. Introduction –Database System –Access, SQL Server and others. –Microsoft Access - Interacting with this databases.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
Why are Databases Better than Files? Multiple users can all use the same database, and have access to the current, up to the minute values for the data.
DAY 14: MICROSOFT ACCESS – CHAPTER 1 Madhuri Siddula October 1, 2015.
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.
What have we learned?. What is a database? An organized collection of related data.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
Database Management Supplement 1. 2 I. The Hierarchy of Data Database File (Entity, Table) Record (info for a specific entity, Row) Field (Attribute,
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
Access Lessons 1, 2 and 3 ©2009 M and K Solutions, LLC – All Rights Reserved.
Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 25 I’m Suffering from Information Overload.
Chapter 24 I’m Suffering from Information Overload (Access Databases) Clearly Visual Basic: Programming with Visual Basic nd Edition.
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
Chapter 1 Introduction to Database. Database Concept Field: a basic data element or attribute of an object Record: a set of fields Table: a set of records.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
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.
Introduction to Business Information Systems by Mark Huber, Craig Piercy, Patrick McKeown, and James Norrie Tech Guide D: The Details of SQL, Data Modelling,
VOCAB REVIEW. A field that can be computed from other fields Calculated field Click for the answer Next Question.
Data Access Objects .
The Recordset Object.
Chapter 4 Relational Databases
Databases and Information Management
What is a Database and Why Use One?
Databases and Information Management
Working With Databases
Unit – V Data Controls.
Presentation transcript:

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 1 Chapter 9: Introduction to Working with Databases in Visual Basic

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 2 Database Concepts Database: the storage of different types of data in such a way that the data can be easily manipulated and retrieved by an end user. A database is composed of fields, records, and tables. Field: a single fact or data. It is the smallest use of named data that has meaning in a database. Fields are given field names to identify them. Record: A collection of related data that is treated as a unit. A collection of fields that pertain to a single person, place or thing. Table: A related collection of records, all having the same fields. Composed of rows and columns.

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 3 A Database Table

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 4 Relational Database A relational database is composed of multiple related tables. It is the most common form of database in use today. A primary key is a field that has a unique value for each record in a table. A foreign key is a field that is a primary key in another table. Foreign keys are used to establish the relationships between the various tables in the database.

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 5 Relational Database

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 6 Database Operations The primary use of a database is to enable the user to obtain information from it by constructing queries to it. For a relational database, these queries are constructed using SQL (Structured Queried Language). Once found, records can be displayed, edited, deleted, or added.

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 7 Advantages of Databases vs. Arrays Databases are superior to arrays for the following reasons: –A database table can store multiple types of data in the same table while arrays are restricted to a single data type. –Any changes to the database are immediately saved to disk as they occur. –A sophisticated database engine can be used to handle processing. –Multiple computers can be connected to the same database.

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 8 Using VB to Work with Databases Visual Basic can be used to work with existing databases. In our case, we will assume a Microsoft Access database with an.mdb extension. Visual Basic can be used to create a user-friendly front-end to a database. The data control (with dat prefix) is essential to working with databases in VB. It uses an internal pointer to point to the current record.

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 9 The Data Control DatabaseName property must be set to the pathname of the database. RecordSource property must be set to the table of the database. Textboxes and other controls can be bound to a data control by assigning their DataSource property to the data control. The bound control’s DataField property is set to a field of the DataSource table. The Recordset object represents the records in the database.

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 10 RecordSet Methods There are numerous useful methods for the Recordset object: –MoveFirst - move to first record –MoveLast - move to last record –MoveNext - move to next record –MovePrevious - move to previous record –AddNew - add a new record (save by moving to new record or using UpdateRecord method) –Delete - delete current record –UpdateControls - make bound controls the same as database

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 11 Recordset Properties There are numerous useful properties for the Recordset object: –AbsolutePosition - the current position of pointer –RecordCount - the number of records in the Recordset –BOF (EOF) - True if at Beginning (End) of File –Bookmark - A unique identification of each record

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 12 Finding Records The form of the FindFirst method to find first occurrence of a matching record is: datName.Recordset.FindFirst Query string where the Query string is in quotation marks and is a combination of field name, comparison operator, and a value. For example: datMembers.Recordset.FindFirst “Late_Fees > 0” If the NoMatch property is true, no record matches the query. An Until NoMatch loop can be used with the FindNext method to find all matches.

Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database The Data Control The Recordset Object Finding Records Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy 13 The Field Property and More on Query Strings To find the value of a field of the current record, use the RecordSet Field property, e.g., datMembers.Recordset(“Name”) A query string can be the combination of the field name and the comparison operator with some value--this enables variable query strings Strings in query strings must be enclosed in apostrophes, e.g., “Phone Number = “ & “’” & PhoneNum & “’”