Working with Database in ASP

Slides:



Advertisements
Similar presentations
Basics of Database Programming with VB6
Advertisements

CIS 375—Web App Dev II ADO I. 2 Introduction ADO (________ Data Objects) is a Microsoft technology for accessing data in a database. ADO is automatically.
Chapter 10 ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a programming interface to access data in a database.
Session 6 Server-side programming - ASP. An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side.
The ADO Data Control. Universal Data Access Open Database Connectivity (ODBC) –standard for accessing data in databases OLE-DB –allows access to data.
 ADO Object Model  Database Connection  Record Set  Query Examples  Update & Insertion Examples  An Application Example Working with Database in.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall COS 346 Day 23.
1 Active Server Pages Active Server Pages (ASPs) are Web pages ASP = server-side scripts + HTML The appearance of an Active Server Page depends on who.
4/8/99 C. Edward Chow Page 1 Active Server Page It is a server-side scripting environment for creating dynamic content. ASP are files with.asp extension,
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.
CSE 190: Internet E-Commerce Lecture 13: Database code.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
DT221/3 Internet Application Development Active Server Pages & Database Connection.
Connecting to Microsoft SQL Server Tuc Goodwin. Introduction We are going to discuss establishing an connection to a SQL Server Database. You will learn.
1 Client/Server Database Tutorial. SQL Server Connection through MS Access FACBUSAD1 SQL server MS Access MGD B106 Computer or your own PC Remote SQL.
Overview of Database Access in.Net Josh Bowen CIS 764-FS2008.
Microsoft Access Ervin Ha.
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
FrontPage 2000 Web Page Database Connectivity. Client /Server Architecture Database Server PCs Middleware.
CSCI 6962: Server-side Design and Programming
1 Lecture 3 Web Technologies Part 2. 2 l HTML l XHTML l CSS l XML l JavaScript l VBSCRIPT DOM l DHTML l AJAX l E4X l WMLScript l SQL Web Technologies.
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.
Interacting With Data Databases.
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
ActiveX Data Object (ADO) in JavaScript J.L.Wang, Yen-Cheng Chen Dept. of Infomation Management Ming-Chuan University Jan
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
© 2006 ITT Educational Services Inc. Course Name: IT390 Business Database Administration Unit 9 Slide 1 IT 390 Business Database Administration Unit 9:
Data-Enabled Web Sites: Classibooks.com & Internet Database Technologies Colin Fukai April 4, 2000 Gonzaga University.
Database 20/2/12 Connection. 
1 Tutorial 2 ABC Web site. Objective Learning web applications design Conducting assumed business logic online Connecting the Database with the web pages.
Server Side Programming ASP1 Server Side Programming Database Integration (cont.) Internet Systems Design.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting Tutorial 10.
File Processing Concepts – Field – combination of 1 or more characters that is the smallest unit of data to be accessed – Record – group of related fields.
Introduction to ADO Y.-H. Chen International College Ming-Chuan University Fall, 2004.
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.
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.
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.
Database Management Systems CS 420. Topics Outline 1. Introduction 2. HTML Review 3. VBScript 4. Access DBMS 5. Relational Database 6. Design Process.
Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation.
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.
Database Connectivity What is ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a Microsoft Active-X component.
Database Connectivity and Server-Side Scripting Chapter 12.
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
ADO.NET Architecture MIS3502: Application Integration and Evaluation David Schuff Adapted from material by Arnold Kurtz, David.
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.
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.
Using databases ActiveX Data Objects (ADO) Connecting to a database Reading data from a database Inserting, updating and deleting records Using databases.
Chapter 5 Building Your Product Catalog database Objectives Create Database. Create Table. Connect to Database. Use ASP Script to add new products. Use.
Web based Documentation Distribution Tools: MSAccess database (DSN) DreamWeaver Ultradev Microsoft Image Composer Clicking on the document will open an.
Lecture 4 Manipulating Form Data using methods of Recordset and RecordsetClone in VBA Restrict data with filter 1 Rapid Application Development.
ASP.NET Programming with C# and SQL Server First Edition
Visual Basic Database Access
Accessing the Database Server: ODBC, OLE DB, and ADO
Web Systems & Technologies
ActiveX Data Objects (ADO)
ADO.NET Accessing Databases in VS.NET
PHP-language, database-programming
VISUAL BASIC INTRODUCTION TO DATA CONNECTIVITY.
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Chapter 10 ADO.
Database Connections.
ASP Database Operations
Presentation transcript:

Working with Database in ASP ADO Object Model Database Connection Record Set Query Examples Update & Insertion Examples An Application Example

ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO Object Model ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a Microsoft Active-X component ADO is automatically installed with Microsoft IIS ADO is a programming interface to access data in a database ADO can be accessed from within your Active Server Pages

Relationships Among the Objects

Accessing a Database from an ASP Page The normal way to access a database from inside an ASP page is to: Create an ADO connection to a database Open the database connection Create an ADO recordset Open the recordset Extract the data you need from the recordset Close the recordset Close the connection

Database Connection The easiest way to connect to a database is to use a DSN-less connection. A DSN-less connection can be used against any Microsoft SQL database on your web site. If you have a database called "northwind " located in your SQL Server, you can connect to the database with the following ASP code:

Database Connection, cont. Create a file called “ADOConnection.asp” and type in the code below <% dim connobj dim connstr connstr = "Provider=SQLOLEDB;Data Source=MyServer;Database=Northwind;User Id=NorthUser;Password=abc;" set connobj = Server.CreateObject("ADODB.Connection") connobj.Open (connstr) connobj.Close set connobj = nothing %> 2. The ADO Connection object is used to create an open connection to a data source. Through this connection, you can access and manipulate a database.

Create an ADO Table Recordset 1.Create the file “ADORecordset.asp” and type in the code below <% dim connobj dim connstr dim recobj connstr = "Provider=SQLOLEDB;Data Source=MYSERVER;Database=Northwind;User Id=NorthUser;Password=abc;" set connobj = Server.CreateObject("ADODB.Connection") connobj.Open (connstr)'this part create and assign the recordset. set recobj = Server.CreateObject("ADODB.Recordset") 'open the table customer using connobj as the default connection. recobj.Open "Customers", connobj Response.Write("Table Customers opened.") connobj.Close recobj.close set recobj = nothing set connobj = nothing %>

Extract Data from the Recordset Create a file called “ADORecordset2.asp” and type in the code below: <% dim connobj dim connstr dim recobj connstr = "Provider=SQLOLEDB;Data Source=MYSERVER;Database=Northwind;User Id=NorthUser;Password=abc;" set connobj = Server.CreateObject("ADODB.Connection") connobj.Open (connstr) 'this part create and assign the recordset. set recobj = Server.CreateObject("ADODB.Recordset") 'open the table customer using connobj as the default connection. recobj.Open "Customers", connobj Response.Write("Table Customers opened.<br />") 'retrieve data

Extract Data from the Recordset, cont. for each x in recobj.fields response.write(x.name) response.write(" = ") response.write(x.value & "<br />") next connobj.Close recobj.Close set recobj = nothing set connobj = nothing %>

Closing Recordset and closing Connection 1.After using the recordset and connection object, it is important to properly close and destroy the objects. 2.Below is the 4 lines necessary to perform such operations. Recobj.close Connobj.close Set recobj = nothing Set connobj = nothing

Database Connection Examples ODBC source connection example: Set myDBConnection = Server.CreateObject( "ADODB.Connection" ) ConnStr = “DSN=airline db; uid=cis8490; pwd=test” myDBConnection.open connStr OLE connection example Set myDBConnection = Server.CreateObject( "ADODB.Connection " ) myDBConnection.Open “PROVAIDER=SQLOLEDB; DATA SOURCE = yourserver; UID=sa; PWD=secret; DATABASE=Pubs ” ODBC Driver For Trusted Connection security connection example myDBConnection.Open "Driver={SQL Server};" & _           "Server=MyServerName;" & _           "Database=myDatabaseName;" & _           "Uid=;" & "Pwd=;"

A Recordset object: the entire set of records Opened from a base table Recordset Objects A Recordset object: the entire set of records Opened from a base table Created by the results of an executed query Record object: an record in the recordset Current record Only a single record can be referenced at any time Field object: an attribute (field) in a record Can be referenced by the attribute name or by its position (index)