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.

Slides:



Advertisements
Similar presentations
Data Base. Objective Become familiar with database terminology. Create a project to display data for a single database table. Use a DataGrid control.
Advertisements

Copyright ®xSpring Pte Ltd, All rights reserved Versions AuthorDateDescription 1.0NBL2012/05First version. Modified from Enterprise edition.
Mark Dixon, SoCCE SOFT 131Page 1 24 – Web applications: Writing data to Databases using ASP.
1 Chapter 12 Working With Access 2000 on the Internet.
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.
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.
 ADO Object Model  Database Connection  Record Set  Query Examples  Update & Insertion Examples  An Application Example Working with Database in.
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,
Mark Dixon, SoCCE SOFT 131Page 1 22 – Web applications: Writing data to Databases using ASP.
CSE 190: Internet E-Commerce Lecture 13: Database code.
Mark Dixon Page 1 20 – Web applications: Writing data to Databases using ASP.
4/8/99 C. Edward Chow Page 1 Internet Services Manager Click Start | Programs | Administrative Tools | Internet Services Manager.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
DT221/3 Internet Application Development Active Server Pages & Database Connection.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: Writing data to Databases using ASP.
Exporting Data and Creating Financial Reports with Excel and Crystal Slide 1 Exporting Data and Creating Financial Reports with Excel and Crystal By Peter.
ODBC and JDBC What are they – libraries of function calls that support SQL statements Why do we need them –Provide a way for an application to communicate.
How to using MS Access database in Perl/CGI Web Programming Wei Sun.
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
Michael Tucker DBA / Webmaster Forsyth County Public Library.
CIS 270—App Dev II Big Java Chapter 22 Relational Databases.
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.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
Interacting With Data Databases.
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
ADO Connect Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
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.
Database 20/2/12 Connection. 
Connecting to USF Network for Web Site SSH Secure Shell is the FTP program you will use to download your http files onto the USF server. To get the SSH.
CIS 270—Application Development II Chapter 25—Accessing Databases with JDBC.
© Michelle C. Heckman All Rights Reserved. v6.0 Dreamweaver “UltraDev” CS125UDF This course qualifies as a CAS Web Master Related Elective.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using ASP.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting Tutorial 10.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Introduction to ADO Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Lecture Note 10: Simple Database Techniques. Introduction –Database System –Access, SQL Server and others. –Microsoft Access - Interacting with this databases.
WebOPAC Installation for SOUL 2.0 is divided in 4 Steps:
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.
Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Adding an ODBC source ODBC is Windows’ way of talking to a database Start->Settings-> Control Panel-> ODBC Data Sources Do not try this until I send you.
Ch. 101 Database Management An Introduction to Databases.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 8 – Integrating a Database with a FrontPage.
Microsoft FrontPage 2003 Illustrated Complete Integrating a Database with a Web Site.
Mark Dixon, SoCCE SOFT 131Page 1 23 – Web applications: Databases & ASP.
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.
What’s new in ADO 2.5 Greg Hinkel Program Manager Data Access Group
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
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
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.
Creating SQL Database file And Displaying a Database Table in a DataGridView.
Migrating Wordpress Migrating Wordpress can sometimes get more complicated as it should. There is no plugin that does this for you, the best way is to.
ASP.NET Programming with C# and SQL Server First Edition
Creating Data Base & Sql Data Source
Working with Database in ASP
Chapter 10 ASP and Data Store Access
Go to PC1.
Chapter 7 Searching Your Products
Database Connections.
ASP Database Operations
Presentation transcript:

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 installed with _____. The common way to access a database from within an ASP page is to: Create an ADO ___________ to a database Open the database connection Create an ADO __________ Open the recordset Extract the data you need from the recordset Close the recordset Close the connection

3 Database Connections Before a DB can be accessed from a web page, a DB connection must be established. The easiest way to connect to a DB is to use a DSN- _____ connection.DSN A DSN-less connection can be used against any _______________ DB on your web site.

4 Create a DSN for an ODBC DB Note that this configuration has to be done on the computer where your web site is located. 1. Open the ODBC icon in your Control Panel. 2. Choose the System DSN tab. 3. Click on Add in the System DSN tab. 4. Select the Microsoft Access Driver. Click Finish. 5. In the next screen, click Select to locate the database. 6. Give the database a Data Source Name (DSN). 7. Click OK. If your web site is located on a remote server, you must have _________ access to that server, or ask your web host to do this for you.

5 Create/Open a DB Connection For an Access DB called “hr.mdb" in a folder called “fpdb” with your ASP file in the _____ directory, this code creates and opens a DSN-less ADO connection. <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath(“fpdb/hr.mdb")) …%> If you have an ODBC DB with a _____ called “hr," connect to the DB with the following ASP code:ODBC <% set conn=Server.CreateObject("ADODB.Connection") conn.Open “hr" …%>

6 Create/Open a Recordset To be able to read database data, the data must first be loaded into a _________. If you opened the DB connection with the first set of code in the previous slide, you can access the “employee" table by adding the following code: set rs=Server.CreateObject("ADODB.recordset") rs.Open "employee", conn Or you could use _____ as follows: set rs=Server.CreateObject("ADODB.recordset") rs.Open "Select * from employee", conn This stores all table records in the recordset.

7 Display Data To extract data from a recordset and then close the recordset and connection, add the following code: do until rs.EOF for each x in rs.Fields ‘ “x” refers to a field Response.Write(x.name) ‘ field name Response.Write(" = ") Response.Write(x.value & " ") ‘ field value next Response.Write(" ") rs.MoveNext ‘ move to next record in table loop rs.close conn.close

Display Data in an HTML Table File named display_employees.aspdisplay_employees.asp <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath("fpdb/hr.mdb")) set rs=Server.CreateObject("ADODB.recordset") sql="SELECT * FROM employee" rs.Open sql, conn %> <% for each x in rs.Fields response.write(" " & x.name & " ") next %> <% for each x in rs.Fields %> <% Response.Write(x.value) %> <% next rs.MoveNext %> <% loop rs.close conn.close %>

9 Add Records I First create a form for data input (form.htm):form.htm SSN: Last Name: First Name:

10 Add Records II Then create the ASP file to add records (add.asp): <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath(“fpdb/hr.mdb")) sql="INSERT INTO employee (ssn,lastname,firstname) VALUES " sql=sql & "('" & Request.Form("ssn") & "'," sql=sql & "'" & Request.Form(“lastname") & "'," sql=sql & "'" & Request.Form(“firstname") & "')" on error resume next conn.Execute sql,recaffected if err<>0 then Response.Write("No update permissions!") else Response.Write(" " & recaffected & " record added ") end if conn.close %>

Update Records IUpdate Records I: hr_listforupdate.asphr_listforupdate.asp This file displays all records in a special way (continues on next slide): <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath("../db/hr.mdb")) set rs=Server.CreateObject("ADODB.Recordset") rs.open "SELECT * FROM employee",conn %> List Database <% for each x in rs.Fields response.write(" " & ucase(x.name) & " ") next %>

hr_listforupdate.asp (continued) <% for each x in rs.Fields if x.name="ssn" then%> "> <%end if next %> <% loop conn.close %>

Update Records II: hr_update.asp Update Record <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath("fpdb/hr.mdb")) social=Request.Form("ssn") if Request.form("lastname")="" OR Request.form("firstname")="" then set rs=Server.CreateObject("ADODB.Recordset") rs.open "SELECT * FROM employee WHERE ssn ='" & social & "'", conn %> " value=" " size="20">

hr_update.asp (continued) <% else sql="UPDATE employee SET " sql=sql & "lastname='" & Request.Form("lastname") & "'," sql=sql & "firstname='" & Request.Form("firstname") & "'" sql=sql & " WHERE ssn='" & social & "'" on error resume next conn.Execute sql if err<>0 then response.write("No update permissions!") else response.write("Record " & social & " was updated!") end if conn.close %>

15 Delete Records IDelete Records I: hr_listfordelete.asp hr_listfordelete.asp This file is identical to hr_listforupdate.asp except for the following code: instead of:

16 Delete Records II: hr_delete.asp This file is identical to hr_update.asp except for the following code: sql="DELETE FROM employee" sql=sql & " WHERE ssn='" & social & "'" instead of: sql="UPDATE employee SET " sql=sql & "lastname='" & _ Request.Form("lastname") & "'," sql=sql & "firstname='" & _ Request.Form("firstname") & "'" sql=sql & " WHERE ssn='" & _ social & "'"

17 ADO Demonstration How to change the ________ rights of your Access database: Open Windows Explorer, find the.mdb file. Right-click on the.mdb file and select ___________. Go to the _________ tab and set the access-rights here. List, edit, update, and delete database records Add a new record

18 Using Access & FrontPage SMSU Computer Services has a web page describing how to create a database connection using MS Access and FrontPage software.web page SMSU Computer Services also has a tutorial on how to set up a form on a web page and connect it to an Access database.tutorial