Source = Table rsObject.Open tablename, Connection Object, CursorType, LockType, adCmdTable Source = Stored Procedure rsObject.Open stored procedure name,

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.
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.
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.
Programming the RecordSet Object
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.
Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab10 Interacting with Data (Database Management)
CIS 451: ASP Recordsets Dr. Ralph D. Westfall May, 2002.
A Guide to SQL, Seventh Edition. Objectives Embed SQL commands in PL/SQL programs Retrieve single rows using embedded SQL Update a table using embedded.
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”
Microsoft Access 2010 Chapter 7 Using SQL.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
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.
Using the Select Case Statement and the MsgBox Function (Unit 8)
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.
ADO.NET Tools and Wizards. Slide 2 Data Sources Window (Introduction) Use the Data Sources window to Establish a connection Create bound control instances.
Database actions In this presentation… –database actions –database connections –recordsets.
Dinamic SQL & Cursor. Why Dinamic SQL ? Sometimes there is a need to dynamically create a SQL statement on the fly and then run that command. This can.
Stored Procedures, Transactions, and Error-Handling
Form and Graphical User Interfaces. Lesson plan More about queries More about entering data into a table Form.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
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.
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.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
Unbound Form Form not tied directly to any fields in the database Must use SQL to “bind” the fields 1.
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.
Android - SQLite Database 12/10/2015. Introduction SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with.
1 CS 3870/CS 5870: Note07 Prog 4. Master Pages Creating a master page based on another master page MainMasterPage –For all Progs and Tests Prog4MasterPage.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 6: Accessing a database with PHP Rob Gleasure robgleasure.com.
Labtest.ASP Notes. INSERT STATUS INSERT STATUS
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.
Form and Graphical User Interfaces. Lesson plan More about queries More about entering data into a table Form.
Using databases ActiveX Data Objects (ADO) Connecting to a database Reading data from a database Inserting, updating and deleting records Using databases.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
 2 Data Object Library approaches ◦ DAO (Data Access Objects)  Original access strategy (up to VB6)  Closely linked to MS Access ◦ ADO (ActiveX Data.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
ASP.NET Programming with C# and SQL Server First Edition
Visual Basic Database Access
Visual Basic Database Programming.
Data Access Objects .
ADO VBA Programming in Access
Find, filter etc with connection to Access code internally
A Guide to SQL, Seventh Edition
ActiveX Data Objects (ADO)
The Recordset Object.
INT213 Updating the Database.
Handling Exceptions.
VB.NET Using Database.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Working With Databases
Excel Import data from Access to Excel (ADO) using VBA
Source: Link Posted By: HeelpBook Permalink: Link
Presentation transcript:

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

Requery Method Updates the data in a Recordset object by re-executing the query on which the object is based. Syntax recordset.Requery Options Use the Requery method to refresh the entire contents of a Recordset object from the data source by reissuing the original command and retrieving the data a second time. Calling this method is equivalent to calling the Close and Open methods in succession. If you are editing the current record or adding a new record, an error occurs. *Note - Use after inserting, deleting, and updating Update Method Saves any changes you make to the current row of a Recordset object RecordSet

The Command Object Use a Command object to execute queries. Queries that return records Queries that return no records (Insert, delete etc) Important Propeties and Methods CommandText -Indicates the text of a command to be issued against a provider. CommandType -Indicates the type of a Command object. adCmdUnspecified adCmdText –use for SQL adCmdTable adCmdStoredProc CommandTimeout - Indicates how long to wait while executing a command before terminating the attempt and generating an error. ActiveConnection -Indicates to which Connection object the specified Command currently belongs Execute

The Command Object Execute -Executes the query, SQL statement, or stored procedure specified in the CommandText property. For a Recordset-returning Command: Set recordset = command.Execute( RecordsAffected, Parameters, Options ) For a non–recordset-returning Command: command.Execute RecordsAffected, Parameters, Options Usually command.Execute

The Command Object Dim Cnxn As ADODB.Connection Dim cmdChange As ADODB.Command Dim strSQLChange As String Dim strCnxn As String strSQLChange = "UPDATE Titles SET Type = 'self_help' WHERE Type = 'psychology'“ strCnxn = "Provider=sqloledb;Data Source=MyServer;Initial Catalog=Pubs;User Id=sa;Password=; " Set Cnxn = New ADODB.Connection Cnxn.Open strCnxn Set cmdChange = New ADODB.Command Set cmdChange.ActiveConnection = Cnxn cmdChange.CommandText = strSQLChange cmd.Execute

Common Database Operations Navigation Use MoveFirst, MoveLast, MoveNext, and MovePrevious methods of recordset. recordset.MoveNext Adding a Record Dim Cnxn As ADODB.Connection Dim rstEmployees As ADODB.Recordset Dim strCnxn As String Dim strSQL As String Dim strID As String Dim strFirstName As String Dim strLastName As String Dim blnRecordAdded As Boolean ' Open a connection Set Cnxn = New ADODB.Connection strCnxn = "Provider=sqloledb;Data Source=MyServer;Initial Catalog=Northwind;User Id=sa;Password=;“ Cnxn.Open strCnxn

' Open Employees Table with a cursor that allows updates Set rstEmployees = New ADODB.Recordset strSQL = "Employees" rstEmployees.Open strSQL, strCnxn, adOpenKeyset, adLockOptimistic, adCmdTable ' Get data from the user strFirstName = Trim(InputBox("Enter first name:")) strLastName = Trim(InputBox("Enter last name:")) If strFirstName <> "" And strLastName <> "" Then rstEmployees.AddNew rstEmployees!FirstName = strFirstName rstEmployees!LastName = strLastName rstEmployees.Update

' Show the newly added data MsgBox "New record: " & rstEmployees!EmployeeID & " " & _ rstEmployees!FirstName & " " & rstEmployees!LastName Else MsgBox "Please enter a first name and last name." End If ' clean up rstEmployees.Close Cnxn.Close Set rstEmployees = Nothing Set Cnxn = Nothing

Common Database Operations Adding a Record - alternate way Dim cmdEmp As ADODB.Command Set cmdEmp = New ADODB.Command cmdEmp.ActiveConnection = Cnxn cmdEmp.CommandType = adCmdText If strFirstName <> "" And strLastName <> "" Then cmdEmp.CommandText = "Insert into Employees(FirstName, LastName) values(‘" & strFirstName & “’, ‘" & strLastName & ‘")" cmdEmp.Execute rstEmployees.Requery

Deleting a Record Deleting a record Dim cmdEmp As ADODB.Command Set cmdEmp = New ADODB.Command cmdEmp.ActiveConnection = Cnxn cmdEmp.CommandType = adCmdText cmdEmp.CommandText = "DELETE FROM Employees WHERE EmployeeID = '" & strID & "'" cmdEmp.Execute rstEmployees.Requery

Menu Choices File – Exit Select – By LastName, By FirstName, By All Patients Sort – By Patient Number, By Patient Name