ASP-13-1 Recordsets Colorado Technical University IT420 Tim Peterson.

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.
ASP Application Development Session 3. Topics Covered Using SQL Statements for: –Inserting a tuple –Deleting a tuple –Updating a tuple Using the RecordSet.
Prentice Hall © COS 346 Day Agenda Capstone Progress report due Assignment 9 not corrected yet Assignment 10 posted (last one!!!) –Due.
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.
VB.NET Database Tools ISYS Net Applications OLE DB Provider OLE DB Data Source OLE DB Provider ODBC Data Source SQL Server Data Source SQL Server.Net.
Using Objects and Properties
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall COS 346 Day 23.
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
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.
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.
Mark Dixon Page 1 20 – Web applications: Writing data to Databases using ASP.
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.
4-1 INTERNET DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
ActiveX Data Object (ADO) in JavaScript J.L.Wang, Yen-Cheng Chen Dept. of Infomation Management Ming-Chuan University Jan
© 2006 ITT Educational Services Inc. Course Name: IT390 Business Database Administration Unit 9 Slide 1 IT 390 Business Database Administration Unit 9:
1 VBScript Session What we learn last session?
Introduction to ADO By David R. Stevenson Consulting Software Engineer ABB Automation.
Beginning Databases with JDBC Mike Bradley Adapted from and notes by Kevin Parker, Ph.D.
Server Side Programming ASP1 Server Side Programming Database Integration (cont.) Internet Systems Design.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using ASP.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
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.
ADO 2.5 Kamaljit Bath, Program Manager Data Access Group.
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.
ASP.NET - accessing the database - datareader vs dataset - datagrid vs datalist - brief look at web matrix.
Internet Programming ASP Sara Shahzad Dept. of Computer Science UOP.
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.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
ASP-12-1 Data Store Access Colorado Technical University IT420 Tim Peterson.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
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,
ASP-14-1 Advanced ASP Techniques Colorado Technical University IT420 Tim Peterson.
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.
Labtest.ASP Notes. INSERT STATUS INSERT STATUS
DML Statements contd.. SQL Server CURSORS Cursor is used in handling results of select query for data calculations Cursors are used as buffered.
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.
 2 Data Object Library approaches ◦ DAO (Data Access Objects)  Original access strategy (up to VB6)  Closely linked to MS Access ◦ ADO (ActiveX Data.
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.
Chapter 6 Displaying Your Products
Chapter 10 ASP and Data Store Access
Chapter 8 Advanced SQL.
Working With Databases
Presentation transcript:

ASP-13-1 Recordsets Colorado Technical University IT420 Tim Peterson

ASP-13-2 What is a Recordset? Recordset object is more than just the data. It has functionality which allows us to: –Manipulate data –Add data –Delete data –Hide records –Search for data within a record

ASP-13-3 Cursors Cursors are used to find your way around Recordsets. Cursors can point at an individual record object. Names of the field can then be used to identify individual cells of interest. Example cursor methods are: –MoveFirst, MoveLast, and MoveNext

ASP-13-4 Recordset creation Recordsets can be create via various methods. Dim objRS Set objRS = Server.CreateObject(“ADODB.Recordset”) To create the connection: Dim strConn, objConn, objRS strConn = “Provider=Microsoft.Jet-OLEDB.4.0;Data Source=C:\Movie2000.mdb Set objConn = Server.CreateObject(“ADODB.Connection”) objConn.Open strConn Set objRS = Server.CreateObject(“ADODB.Recordset”) objRS.Open “Movies”, objConn

ASP-13-5 Avoiding Explicit Connection Objects ADO can hide the interdependence of code, making the coding of connections easier. To open a Recordset directly: Dim objRS, strConnect strConn = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Movie2000.mdb” Set objRS = Server.CreateObject(“ADODB.Recordset”) objRS.Open “Movies”, strConnect

ASP-13-6 Implicit Recordset Creation <% Option Explicit Dim strConnect %> ADO Recordset Object <% Const adOpenForwardOnly = 0 Const adLockReadOnly = 1 Const adCmdTable = 2 Dim objRS ' recordset object Set objRS = Server.CreateObject ("ADODB.Recordset") ' create recordset object objRS.Open "Movies", strConnect, _ adOpenForwardOnly, adLockReadOnly, adCmdTable ' now open it While Not objRS.EOF ' now loop through the records Response.Write objRS.Fields("Title") & ", " objRS.MoveNext Wend objRS.Close ' now close it Set objRS = Nothing '...and clean up %>

ASP-13-7 ADO Constants ADO has many pre-defined constants which are used to specify options. As opposed to just using the numbers, we define the constants so that the code is easier to read. The constant names are defined in msado15.dll. So that we do not have to define these constants, we can use the dll as follows:

ASP-13-8 Open Method Characteristics recordset.Open Source, ActiveConnection, CursorType, LockType, Options Source - Defines where the data comes from. Active Connection - Identifies the data store connection (e.g. strConnect). Cursor Type - By defining the cursor type, we define the functionality we want with the recordset.

ASP-13-9 Cursor Types Cursor must be defined when the recordset is opened. Forward-Only - This is the default and only allows us to move forward through a recordset. Static - Similar to forward-only with the additional ability to scroll backwards in the recordset. Dynamic - Allows you to see changes to the recordset that are made by other users (additions, deletions, etc.) Keyset - Similar to dynamic except that you can’t see records added by other people.

ASP LockType LockType determines if records are updateable. Types of locks are: –Read-only - The recordset can not be updated. This is the default. –Pessimistic - Provides an updateable recordset. –Optimistic - Provides an updateable recordset with a carefree lock. –Optimistic Batch - Allows you to make multiple updates to the recordset and update the data store all at once. Locking is the same as optimistic.

ASP Options Used to define what what type of data source is being connected to. They are: –adCmdText - Indicates that the source parameter holds a text command such as a SQL statement. –adCmdTable - Indicates the source holds a table name. –adCMDStoredProc - Indicates that source holds the name of a stored procedure or query. –adCmdFile - Indicates source holds the name of a file which is a saved recordset. –adCMDURLBind - Indicates the source holds a URL.

ASP Cursor Movement MovePrevious and MoveNext - Allows the cursor to move to the immediately preceding or next record. MoveFirst and MoveLast - Moves the cursor to the first or last record in a recordset. Usage is as follows: objRS.MoveLast

ASP Cursor Movement - Move A fifth method exists Move - Used to jump over a specified number of records. objRecordset.Move NumRecords, Start NumRecords specifies the number of records to jump. Start specifies where in the recordset we want to start from.

ASP Bookmarks Bookmarks are used for marking a record in a recordset Not all Recordsets support bookmarks. Example bookmark usage code: Dim varMyBookmark ….code to create the Recordset Object varMyBookmark = objRS.Bookmark …Record processing code objRS.Bookmark = varMyBookmark

ASP Searching Records The Find method is a full table scan. Find syntax is as follows: objRecordset.Find Criteria, SkipRecords, SearchDirection, Start Criteria - defines the string to be found SkipRecords - offset from the start position (0) SearchDirection - either adSearchForward (default) or adSearchBackward Start - a bookmark that specifies a start position.

ASP Filtering Records Involves finding all occurrences of a record that match a search string. This allows you to hide records of no importance. By default, filtering is turned off. Example filter code: objRS.Filter = “Instructor = ‘Don Adams’”

ASP Filtering Methods adFilterNone - Turns off all filtering. adFilterPendingRecords - Shows only records that have changed in the recordset but not the data store. (Only works with batch update). adFilterAffectedRecords - Shows only records affected by the last Delete, Resynch, UpdateBatch, or CancelBatch call. adFilterFetchedRecords - Shows records from the last call to retrieve records from the data store.

ASP Fields Collection This collection allows us to use all of the fields in a recordset. Each Recordset object has it’s own fields collection. We can also find out field names with the Fields collection.

ASP Recordsets in Arrays GetRows method places recordset data in an array. Code example is as follows: varArray = objRecordset.GetRows (Rows, Start, Fields) Rows - Allows us to restrict number of records placed in the array. Start - This is a bookmark that defines what record to start on. Fields - Specifies the fields to be placed in the array.