Data Access Objects .

Slides:



Advertisements
Similar presentations
Basics of Database Programming with VB6
Advertisements

1 Chapter 10 Protecting Data Integrity in a Multiuser Environment.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
1 Chapter 12 Working With Access 2000 on the Internet.
ActiveX Data Object ISYS 562. ADO An ActiveX control ActiveX is build upon COM, a contract that defines a standard interface by which objects communicate.
CVEV 118/698 Database Programming Lecture 1 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
VBA Data Access Object. Data Access Objects DAO With DAO we can: –Run queries –Update values in database tables –Create structure of databases Tables,
Using Objects and Properties
Database Connectivity Session 2. Topics Covered ADO Object Model Database Connection Retrieving Records Creating HTML Documents on-the-fly.
Visual Basic Database Access BICS546. Microsoft Universal Data Access OLE DB: The OLE database protocol –Allows a program to access information in any.
CIS 338: Using DAO (Data Access Objects) Dr. Ralph D. Westfall February, 2003.
MySQL and PHP By Trevor Adams.
CIS 451: ASP Recordsets Dr. Ralph D. Westfall May, 2002.
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.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Microsoft Access Ervin Ha.
ADO Recordsets. Recordset Objects Similar to Tables and Queries: data Using VBA/VBScript you… –Open a recordset, –Locate a record –Update or add a record.
Private Sub Close_Click() On Error GoTo Err_Close_Click DoCmd.Close Exit_Close_Click: Exit Sub Err_Close_Click: MsgBox Err.Description Resume Exit_Close_Click.
ActiveX Data Object (ADO) in JavaScript J.L.Wang, Yen-Cheng Chen Dept. of Infomation Management Ming-Chuan University Jan
1 VBScript Session What we learn last session?
Introduction to ADO By David R. Stevenson Consulting Software Engineer ABB Automation.
Java Database Connectivity (JDBC) Introduction to JDBC JDBC is a simple API for connecting from Java applications to multiple databases. Lets you smoothly.
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.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Database actions In this presentation… –database actions –database connections –recordsets.
Chapter 15: Using LINQ to Access Data in C# Programs.
Allowing Multi-user Access Grant – GRANT ON TO – |WITH GRANT OPTION / WITH ADMIN OPTION| – can be PUBLIC or a role – can be all Revoke – REVOKE ON FROM.
Microsoft Access Using Visual Basic Routines. Visual Basic Datatypes Boolean Byte Currency Date Double Integer Long Object Single String Variant Hyperlink.
A few slides on MS Access Record Locking and Transactions.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Copyright © 2001 by Wiley. All rights reserved. Chapter 9: Introduction to Working with Databases in Visual Basic Database Concepts Relational Database.
Recordsets Chapter 7. Recordset Objects Similar to Tables and Queries: data But forms cannot be bound to them Fields cannot be bound to them But Access.
Lecture Note 10: Simple Database Techniques. Introduction –Database System –Access, SQL Server and others. –Microsoft Access - Interacting with this databases.
Visual Basic ADO Programming 56:150 Information System Design.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
You can use Access forms to create an interface to your reports and queries. You can add: Buttons to initiate reports and queries Combo Boxes, List.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
What is database?  Any Method for access info into Application from DataBase?  ODBC is standard for Accessing Data.  Problem with ODBC:  Information.
How to Connect to Database ODBC (Open Database Connectivity) ADO (ActiveX Data Object) ASP Code To Connect to Database Recordset Object Navigating through.
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.
Database Management System. DBMS A software package that allows users to create, retrieve and modify databases. A database is a collection of related.
Unbound Form Form not tied directly to any fields in the database Must use SQL to “bind” the fields 1.
Objects in Access zGeneral Access objects zData access objects (DAO) yused for data management xdata definition xdata manipulation yused only in code modules.
Source = Table rsObject.Open tablename, Connection Object, CursorType, LockType, adCmdTable Source = Stored Procedure rsObject.Open stored procedure name,
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 6: Accessing a database with PHP Rob Gleasure robgleasure.com.
ASP-13-1 Recordsets Colorado Technical University IT420 Tim Peterson.
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.
ADO & Recordsets. ADO Description & History  ActiveX Data Objects  History  1991 ODBC  Data Access Objects (DAO) for VB developers (JET)  Remote.
Lecture 4 Manipulating Form Data using methods of Recordset and RecordsetClone in VBA Restrict data with filter 1 Rapid Application Development.
 2 Data Object Library approaches ◦ DAO (Data Access Objects)  Original access strategy (up to VB6)  Closely linked to MS Access ◦ ADO (ActiveX Data.
ASP.NET Programming with C# and SQL Server First Edition
Visual Basic Database Access
ADO.NET Framework.
SQL and SQL*Plus Interaction
ActiveX Data Objects (ADO)
The Recordset Object.
Database vs. DBMS Database Database Management System
INT213 Updating the Database.
Chapter 8 Working with Databases and MySQL
VISUAL BASIC INTRODUCTION TO DATA CONNECTIVITY.
Chapter 10 ASP and Data Store Access
HAVING,INDEX,COMMIT & ROLLBACK
Working With Databases
Microsoft Access Date.
Unit – V Data Controls.
Presentation transcript:

Data Access Objects 

DBEngine Object The DBEngine object contains and controls all other objects in the hierarchy of DAO objects.

DBEngine Object-Methods Name Description BeginTrans Begins a new transaction. Read/write Database. CommitTrans Ends the current transaction and saves the changes. CreateDatabase Creates a new Database object, saves the database to disk, and returns an opened Database object (Microsoft Access workspaces only). . CreateWorkspace Creates a new Workspace object. OpenConnection Opens a Connection object on an ODBC data source (ODBCDirect workspaces only). OpenDatabase Opens a specified database and returns a reference to the Database object that represents it. Rollback Ends the current transaction and restores the databases in the Workspace object to the state they were in when the current transaction began.

DBEngine Object-Properties Name Description DefaultPassword Sets the password used to create the default Workspace when it is initialized. Read/write String. DefaultType Sets or returns a value that indicates what type of workspace will be used by the next Workspace object created. DefaultUser Sets the user name used to create the default Workspace when it is initialized. Read/write String. Errors Returns an Errors collection that contains all of the stored Error objects for the specified object. Read-only. IniPath Sets or returns information about the Windows Registry key that contains values for the Microsoft Access database engine (Microsoft Access workspaces only). LoginTimeout Sets or returns the number of seconds before an error occurs when you attempt to log on to an ODBC database. Properties Returns the Properties collection of the specified object. Read-only. Version Rreturns the version of DAO currently in use. Read-only String. Workspaces Returns a Workspaces collection that contains all of the active, unhidden Workspace objects. Read-only.

Database object You use the Database object and its methods and properties to manipulate an open database.

Database object-Methods Name Description Close Closes an open Database. CreateProperty Creates a new user-defined Property object (Microsoft Access workspaces only). . CreateQueryDef Creates a new QueryDef object. CreateTableDef Creates a new TableDef object (Microsoft Access workspaces only). Execute Runs an action query or executes an SQL statement on the specified object. NewPassword Changes the password of an existing Microsoft Access database engine database (Microsoft Access workspaces only). OpenRecordset Creates a new Recordset object and appends it to the Recordsets collection.

Database object-Properties Name Description Connect Sets or returns a value that provides information about the source an open database. Read/write String. Connection Returns the Connection object that corresponds to the database (ODBCDirect workspaces only). Returns the name of the specified object. Read-only String. QueryDefs Returns a QueryDefs collection that contains all of the QueryDef objects of the specified database. Read-only. RecordsAffected Returns the number of records affected by the most recently invoked Execute method. Recordsets Returns a Recordsets collection that contains all of the open recordsets in the for the specified database. Read-only. TableDefs Returns a TableDefs collection that contains all of the TableDef objects stored in the specified database. Read-only. Transactions Returns a value that indicates whether an object supports transactions. Read-only Boolean. Updatable Returns a value that indicates whether you can change a DAO object. Read-only Boolean.

Recordset object-Methods A Recordset object represents the records in a base table or the records that result from running a query. Name Description AddNew Creates a new record for an updatable Recordset object. Clone Creates a duplicate Recordset object that refers to the original Recordset object. Close Closes an open Recordset. Edit Copies the current record from an updatable Recordset object to the copy buffer for subsequent editing. FindFirst Locates the first record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). FindLast Locates the last record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

Recordset object-Methods Name Description GetRows Retrieves multiple rows from a Recordset object. Move Moves the position of the current record in a Recordset object. MoveFirst Moves to the first record in a specified Recordset object and make that record the current record. MoveLast Moves to the last record in a specified Recordset object and make that record the current record. MoveNext Moves to the next record in a specified Recordset object and make that record the current record. MovePrevious Moves to the previous record in a specified Recordset object and make that record the current record. Requery Updates the data in a Recordset object by re-executing the query on which the object is based. Seek Locates the record in an indexed table-type Recordset object that satisfies the specified criteria for the current index and makes that record the current record (Microsoft Access workspaces only). Update Saves the contents of the copy buffer to an updatable Recordset object.

Recordset object-Properties Name Description BOF Returns a value that indicates whether the current record position is before the first record in a Recordset object. Read-only Boolean. Bookmark Sets or returns a bookmark that uniquely identifies the current record in a Recordset object. EOF Returns a value that indicates whether the current record position is after the last record in a Recordset object. Read-only Boolean. Fields Returns a Fields collection that represents all stored Field objects for the specified object. Read-only. Filter Sets or returns a value that determines the records included in a subsequently opened Recordset object (Microsoft Access workspaces only). Read/write String. Index Sets or returns a value that indicates the name of the current Index object in a table-type Recordset object (Microsoft Access workspaces only). LastModified Returns a ookmark indicating the most recently added or changed record. LastUpdated Returns the date and time of the most recent change made to a base table. Read-only Variant. NoMatch Indicates whether a particular record was found by using the Seek method or one of the Find methods (Microsoft Access workspaces only). RecordCount Returns the number of records accessed in a Recordset object, or the total number of records in a table-type Recordset object. or TableDef object. Read-only Long. Updatable Returns a value that indicates whether you can change a DAO object. Read-only Boolean.

RecordsetTypeEnum Enumeration Name Value Description dbOpenDynamic 16 Opens a dynaset-type Recordset dbOpenDynaset 2 dbOpenForwardOnly 8 Opens a forward-only type Recordset dbOpenSnapshot 4 Opens a snapshot-type Recordset dbOpenTable 1 Opens a table-type Recordset

Function FindRecordCount(strSQL As String) As Long Dim dbsNorthwind As DAO.Database Dim rstRecords As DAO.Recordset On Error GoTo ErrorHandler Set dbsNorthwind = CurrentDb Set rstRecords = dbsNorthwind.OpenRecordset(strSQL) If rstRecords.EOF Then FindRecordCount = 0 Else rstRecords.MoveLast FindRecordCount = rstRecords.RecordCount End If rstRecords.Close dbsNorthwind.Close Set rstRecords = Nothing Set dbsNorthwind = Nothing Exit Function ErrorHandler: MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description End Function

Dim dbsNorthwind As DAO.Database Dim rstEmployees As DAO.Recordset Set dbsNorthwind = CurrentDb Set rstEmployees = dbsNorthwind.OpenRecordset("Employees") rstEmployees.MoveFirst Do Until rstEmployees.EOF If rstEmployees!Title = "Sales Representative" Then rstEmployees.Edit rstEmployees!Title = "Account Executive" rstEmployees.Update End If rstEmployees.MoveNext Loop

QueryDef object-Methods A QueryDef object is a stored definition of a query in a Microsoft Access database engine database. Name Description Close Closes an open QueryDef. CreateProperty Creates a new user-defined Property object (Microsoft Access workspaces only). Execute Executes an SQL statement on the specified object. OpenRecordset Creates a new Recordset object and appends it to the Recordsets collection.

QueryDef object-Properties Name Description Connect Sets or returns a value that provides information about the source of database used in a pass-through query. Read-only String. Fields Returns a Fields collection that represents all stored Field objects for the specified object. Read-only. MaxRecords Sets or returns the maximum number of records to return from a query against an ODBC data source. RecordsAffected Returns the number of records affected by the most recently invoked Execute method.

TableDef object-Methods A TableDef object represents the stored definition of a base table or a linked table (Microsoft Access workspaces only). Name Description CreateField Creates a new Field object (Microsoft Access workspaces only). . CreateIndex Creates a new Index object (Microsoft Access workspaces only). . CreateProperty Creates a new user-defined Property object (Microsoft Access workspaces only). OpenRecordset Creates a new Recordset object and appends it to the Recordsets collection. RefreshLink Updates the connection information for a linked table (Microsoft Access workspaces only).

TableDef object-Properties Name Description Connect Sets or returns a value that provides information about a linked table. Read/write String. Fields Returns a Fields collection that represents all stored Field objects for the specified object. Read-only. Returns or sets the name of the specified object. Read/write String. RecordCount Returns the total number of records in a TableDef object. Read-only Long. SourceTableName Sets or returns a value that specifies the name of a linked table or the name of a base table (Microsoft Access workspaces only).