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.

Slides:



Advertisements
Similar presentations
Basics of Database Programming with VB6
Advertisements

ADO DB in Access VBA © Walter Milner 2005 Slide: 1 ADO VBA Programming in Access.
1 Chapter 10 Protecting Data Integrity in a Multiuser Environment.
Mark Dixon, SoCCE SOFT 131Page 1 16 – Persistent data storage: relational databases and ADO.
ASP Application Development Session 3. Topics Covered Using SQL Statements for: –Inserting a tuple –Deleting a tuple –Updating a tuple Using the RecordSet.
The ADO Data Control. Universal Data Access Open Database Connectivity (ODBC) –standard for accessing data in databases OLE-DB –allows access to data.
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.
Using ADO Programmatically The Connection Object, Command Object, and Recordset Object.
Using Objects and Properties
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall COS 346 Day 23.
Web-based Programming Lanjut Pertemuan 6 Matakuliah: M0492 / Web-based Programming Lanjut Tahun: 2007.
Programming the RecordSet Object
 2004 Tau Yenny, SI - Binus M0194 Web-based Programming Lanjut Session 6.
Using ADO Programmatically The Connection Object and the Command Object.
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.
Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance.
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.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
ASP & ADO. Connection Object An implicit connection is created when we open a recordset without a connection object. –rs.open “Customer”, "DSN = Sales”
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 12-1 David M. Kroenke’s Chapter Twelve: ODBC, OLE DB, ADO, and ASP Part.
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.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
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.
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
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 11 Accessing Database.
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.
Universal Data Access and OLE DB. Customer Requirements for Data Access Technologies High-Performance access to data Reliability Vendor Commitment Broad.
Faculty of Electronic Engineering 1 Database Access API’s Aleksandar Stanimirović Leonid Stoimenov Aleksandar Milosavljević.
EM412 Using Adaptive Server Anywhere with Visual Basic Ali Chalhoub Technical Support Consultant iAnywhere Solutions
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.
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.
3-Tier Client/Server Internet Example. TIER 1 - User interface and navigation Labeled Tier 1 in the following graphic, this layer comprises the entire.
Notes on ADO from other projects Please use speaker notes for additional information!
Lab 8 Data Access Using Microsoft ActiveX Data Object (ADO)
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
5-1 VISUAL J++ Colorado Technical University IT420 Tim Peterson.
ADO ActiveX Data Object. ActiveX Data Objects (ADO) is Microsoft’s latest database object model. The goal of ADO is to allow VB developers to use a standard.
What’s new in ADO 2.5 Greg Hinkel Program Manager Data Access Group
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.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
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.
Using databases ActiveX Data Objects (ADO) Connecting to a database Reading data from a database Inserting, updating and deleting records Using databases.
Delete Data Database Administration Fundamentals LESSON 3.4.
Generating XML Data from a Database Eugenia Fernandez IUPUI.
 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
Data Access Objects .
ADO VBA Programming in Access
Find, filter etc with connection to Access code internally
ActiveX Data Objects (ADO)
The Recordset Object.
INT213 Updating the Database.
ربط الفيجوال بيسك VB مع قواعد البيانات
Please use speaker notes for additional information!
VISUAL BASIC INTRODUCTION TO DATA CONNECTIVITY.
Chapter 10 ASP and Data Store Access
Excel Import data from Access to Excel (ADO) using VBA
Presentation transcript:

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 to any OLE DB source. ADO

ConnectionCommandRecordset Errors Error Parameters Parameter Fields Field ADO Objects ConnectionAllows control over the connection to the data source RecordsetContains the records that are the result of a query CommandExecutes database commands and queries ErrorContains information about Errors from ADO FieldRepresents a field in a data set ParameterWorks with Command to set parameters for stored procedures or parameter queries PropertyAllows you to access ADO object Properties

Before using ADO, you must establish a reference to the ADO library. Project, References, Microsoft ActiveX Data Objects 2.5 Library Establish Reference to ADO

1.Create a Connection Object. 2.Specify the connection string to connect to the database of interest. 3. Open the connection 4.Create a Recordset object. The Recordset object contains the results of the query after execution. 5.Specify the SQL text. When you open a recordset, you can either use a table, a stored procedure, or string containing a SQL statement. 6.Open the recordset. 7.Opening the recordset executes the query and returns the records to the recordset object. The records are accessible through the recordset object now. Basic Steps to executing a query using ADO

A Connection object represents a unique session with a data source. In the case of a client/server database system, it may be equivalent to an actual network connection to the server. Important Properties and Methods ConnectionString ConnectionTimeout Mode CursorLocation Provider Open and Close Connection Object

'Create ADODB Connection Dim connAVB As ADODB.Connection Set connAVB = New ADODB.Connection connAVB.ConnectionString = "Provider = Microsoft.Jet.OLEDB.3.51;" & "Data Source=" & App.Path & "\AVB.mdb;Mode=readwrite“ connAVB.Open Connection Object

'Create ADODB Connection Dim connAVB As ADODB.Connection Set connAVB = New ADODB.Connection connAVB.ConnectionString = "Provider = Microsoft.Jet.OLEDB.3.51;" & "Data Source=" & App.Path & "\AVB.mdb;Mode=readwrite“ connAVB.Open ‘code connAVB.Close Set connAVB = Nothing Connection Object

Represents the entire set of records from a base table or the results of an executed command. You use Recordset objects to manipulate data from a provider. Important Properties and Methods CursorLocation CursorType LockType Mode Open, Close MoveFirst, MoveLast, MoveNext, and MovePrevious BOF, EOF Update, AddNew, Delete GetString, GetRows Recordset Object

Cursor refers to system resources needed to manage a set of data. Specifies the location of the cursor service. Constant Value Description adUseClient -Uses client-side cursors supplied by a local cursor. Use for desktop applications. adUseServer - Default. Uses data-provider or driver-supplied cursors. These cursors are sometimes very flexible and allow for additional sensitivity to changes others make to the data source. However, some features of the Microsoft Cursor Service for OLE DB (such as disassociated Recordset objects) cannot be simulated with server-side cursors and these features will be unavailable with this setting. CursorLocation

Dynamic cursor — allows you to view additions, changes, and deletions by other users; allows all types of movement through the Recordset Keyset cursor — behaves like a dynamic cursor, except that it prevents you from seeing records that other users add, and prevents access to records that other users delete. Data changes by other users will still be visible. Static cursor — provides a static copy of a set of records for you to use to find data or generate reports; always allows bookmarks and therefore allows all types of movement through the Recordset. Additions, changes, or deletions by other users will not be visible. This is the only type of cursor allowed when you open a client-side Recordset object. Forward-only cursor — allows you to only scroll forward through the Recordset. Additions, changes, or deletions by other users will not be visible. This improves performance in situations where you need to make only a single pass through a Recordset. Cursor Types

LockType is important when you have multiple users accessing the same data. Lock Types Lock TypeConstantResult N/AadLockUnSpecified Read OnlyadLockReadOnlyNo edits OptimisticadLockOptimisticLocked as each update submitted. BatchOptimisticadLockBatchOptimisticLocked when all updates submitted PessimisticadLockPessimisticLocked from Recordset creation

Public Sub MoveX() ' connection and recordset variables Dim rstAuthors As ADODB.Recordset Dim Cnxn As ADODB.Connection Dim strCnxn As String Dim strSQLAuthors As String ' Open connection Set Cnxn = New ADODB.Connection strCnxn = "Provider=sqloledb;Data Source=a-iresmi2000;Initial Catalog=pubs;User Id=sa;Password=;" Cnxn.Open strCnxn ' Open recordset from Authors table Set rstAuthors = New ADODB.Recordset rstAuthors.CursorLocation = adUseClient Opening a RecordSet

strSQLAuthors = "SELECT au_id, au_fname, au_lname, city, state FROM Authors ORDER BY au_lname" rstAuthors.Open strSQLAuthors, strCnxn, adOpenStatic, adLockOptimistic, adCmdText rstAuthors.MoveFirst numRecords = rstAuthors.RecordCount city = rstAuthors!city rstAuthors.Close Cnxn.Close Set rstAuthors = Nothing Set Cnxn = Nothing End Sub Opening a RecordSet

Source = Table rsObject.Open tablename, Connection Object, CursorType, LockType, adCmdTable Source = Stored Procedure rsObject.Open stored procedure name, Connection Object, CursorType, LockType, adCmdStoredProc Source = string rsObject.Open SQLstring, Connection Object, CursorType, LockType, adCmdText Opening a RecordSet