ActiveX Data Objects (ADO) מרצה : דורון אמיר MCSD Doron Amir www.doronamir.com.

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.
Data Base. Objective Become familiar with database terminology. Create a project to display data for a single database table. Use a DataGrid control.
ADO vs ADO.NET ADOADO.NET Client/server coupledDisconnected collection of data from data server Uses RECORDSET object (contains one table) Uses DATASET.
Building ActiveX Controls מרצה : דורון אמיר MCSD Doron Amir
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
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 Visual Basic 6.0 to Create Web-Based Database Applications
Programming the RecordSet Object
Visual Basic Database Access BICS546. Microsoft Universal Data Access OLE DB: The OLE database protocol –Allows a program to access information in any.
CIS 451: ASP Recordsets Dr. Ralph D. Westfall May, 2002.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Overview of Database Access in.Net Josh Bowen CIS 764-FS2008.
© 1999, by Que Education and Training, Chapter 11, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
1 VBScript Session What we learn last session?
Introduction to ADO By David R. Stevenson Consulting Software Engineer ABB Automation.
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.
Using Visual Basic 6.0 to Create Web-Based Database Applications
11 Chapter 10 Customizing a Database with Macros and Visual Basic for Applications Exploring Microsoft Office Access 2007.
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 Access Using Visual Basic Routines. Visual Basic Datatypes Boolean Byte Currency Date Double Integer Long Object Single String Variant Hyperlink.
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
VB Core II Conditional statements Exception handling Loops Arrays Debugging.
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.
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.
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
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.
Notes on ADO from other projects Please use speaker notes for additional information!
Two Forms Please use speaker notes for additional information!
Macro’s Within excel. Most functionality can be driven from VBA VBA is the programming language that runs inside of excel. It uses visual basic as the.
Unbound Form Form not tied directly to any fields in the database Must use SQL to “bind” the fields 1.
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.
Understanding Visual Basic Fundamentals CHAPTER 13 Understanding Visual Basic Fundamentals.
Source = Table rsObject.Open tablename, Connection Object, CursorType, LockType, adCmdTable Source = Stored Procedure rsObject.Open stored procedure name,
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
January 27, 2001Database Tutorial1 Using a Database in ASP.
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.
DATABASE SYSTEM VB LINK TO MS-SQL. 2 Visual ProgrammingChapter 6 Select Project -> Component.
ActiveX DLL Create Class in Dll File & Client Application MCSD Doron Amir
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.
Data Control In this presentation… –databases supported –inserting a data control –data control properties –using the data control.
Generating XML Data from a Database Eugenia Fernandez IUPUI.
1 Methods of Data Processing Applied Database II.
 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
Visual Basic Database Programming.
Find, filter etc with connection to Access code internally
ActiveX Data Objects (ADO)
The Recordset Object.
Database vs. DBMS Database Database Management System
INT213 Updating the Database.
Listing 9.1 ShowLocalConnection.aspx
XML מבוא כללי MCSD Doron Amir
ربط الفيجوال بيسك VB مع قواعد البيانات
עבודה עם נתונים באמצעות ADO.NET
Department Array in Visual Basic
VISUAL BASIC INTRODUCTION TO DATA CONNECTIVITY.
Working With Databases
Presentation transcript:

ActiveX Data Objects (ADO) מרצה : דורון אמיר MCSD Doron Amir

Overview of ActiveX Data Objects (ADO) ADO מאפשר לגשת ולתפעל נתונים ממקור נתונים ADO מספק אובייקטים לניהול נתונים ADO מספק ממשק ויזואלי לניהול מסד הנתונים ADO מאפשר כתיבת קוד עבור ניהול מסד הנתונים ADO תומך בפלטפורמות תכנות שונות  Microsoft Visual Basic  Microsoft Visual InterDev  Microsoft Visual C++  Microsoft Visual J++  Microsoft Visual FoxPro  Microsoft VBScript ADO OLE DB DATA STORE

ADO Object Model Connection ERRORS Recordset FIELDS Command PARAMETERS PROPERTIES 1.אובייקט הקישור יוצר התקשרות אל מסד הנתונים 2.מאפשר לשלוח פקודות למסד הנתונים 3.מאפשר לקבל רשומות. Connection Object

Recordset object 1.מייצג קבוצת רשומות המוחזרות ממסד הנתונים,טבלה או תוצאת שאילתה 2.מכיל אובייקטים ומאפיינים לניהול מערך הרשומות (BOF,EOF,MoveNext) 3.מכיל מאפייני גישה לערכי השדות Value Property BOF USERPASSNAME userD111DORON userA222AMIR EOF

Fields Collection Recotdset מכיל אוסף Fields המייצג את העמודות במערך הרשומות BOF USERPASSNAME userD111DORON userA222AMIR EOF FIELD

Value Property מאפשר לגשת אל ערכי השדות במערך הרשומות BOF USERPASSNAME userD111DORON userA222AMIR EOF

Command Object 1.ADO Command Object מאפשר להפעיל פקודות על מסד הנתונים 2.מחרוזת שאילתה (Query String) 3.שם פרוצדורה מאוחסנת (Store Procedure) Select * From MyTable COMMAND אוסף המכיל פרמטרים עבור Stored Procedure / Query Parameters Parameters Collection אוסף לטיפול בשגיאות המתאר וממספר את ייצוג השגיאה Errors Collection

Connecting to a data source (Connection Object) Connecting to a data source (Connection Object) חיבור וניתוק ממסד הנתונים pubs

Add References … Microsoft ActiveX Data Objects 2.0 Library

Must Add References … ללא הפנייה לא ניתן להגדיר אובייקט התקשרות או כל אובייקט ADO

הגדרת אובייקט קישור + אובייקט מערך רשומות

Connection For SQL Server יצירת מופע 1.ספק 2.אבטחה 3.שם השרת 4.שם מסד הנתונים הודעת התחברות

Retrieving data from a data source (Record Set Object) (Create Recordset & Sql Quert) Retrieving data from a data source (Record Set Object) (Create Recordset & Sql Quert) Open MethodSQL QueryConnection Object

Binding Data & TextBox Controls 1.חיבור הפקד אל מערך הרשומות ע"י Set 2.קישור השדה המיועד

Close & Free Your Objects

OLE-DB Data Provider

Handling data access errors

Error Handler !!! Private Sub cmdConnect_Click() Dim adoErr As Error On Error GoTo ErrHandler:.. … Exit Sub ErrHandler: For Each adoErr In cnPubs.Errors MsgBox "Hi You have Error !!!" & adoErr.Description, vbCritical, "Employee Information" Next End Sub My Connection Code Create an Err Object Go To an ErrHandler Label ErrHandler Label עבור כל שגיאה נקבל תיאור אובייקט השגיאה נמצא באובייקט הקישור

Sorting and searching data

Cursor Location Set rsEmployee = New Recordset rsEmployee.CursorLocation = adUseClient 1.מאחסן את הרשומות במחשב הלקוח 2.מאפשר לנוע קדימה וחזרה ברשומות 3.ללא מאפיין זה לא ניתן לנווט לאחור

MoveNext Private Sub cmdNext_Click() rsEmployee.MoveNext If rsEmployee.EOF Then rsEmployee.MoveLast End If End Sub

Move Previous Private Sub cmdPrevious_Click() rsEmployee.MovePrevious If rsEmployee.BOF Then rsEmployee.MoveFirst End If End Sub

Sort Method Private Sub cmdSort_Click() ‘Check to see if a sort has been applied If rsEmployee.Sort = "" Then ‘No sort, so create one on the author's last name rsEmployee.Sort = "lname DESC" Else ‘There is a sort, so turn it off rsEmployee.Sort = "" End If End Sub

Updating data

Updating rsEmployee.Open "Select emp_id, fname, " & _ “lname from employee ", cnPubs, _ adOpenKeyset, adLockOptimistic adOpenKeyset & adLockOptimistic Private Sub cmdUpdate_Click() Dim Answer As Integer Answer = MsgBox("Do you want update ? ", vbYesNo + vbQuestion, "Update") If Answer = vbYes Then rsEmployee.Update End If End Sub Update Method

ActiveX Data Objects (ADO) מרצה : דורון אמיר MCSD Doron Amir