Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.

Slides:



Advertisements
Similar presentations
ADO DB in Access VBA © Walter Milner 2005 Slide: 1 ADO VBA Programming in Access.
Advertisements

Support.ebsco.com Using the Search History Feature Tutorial.
A new generation of practice management software
Mark Dixon Page 1 23 – Object Oriented Programming in PhP.
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.
Mark Dixon Page 1 16 – Passing Data between pages: Forms, Sessions, & Query Strings.
Mark Dixon Page 1 05 – Database Design: Sub-forms.
Mark Dixon, SoCCE SOFT 131Page 1 16 – Persistent data storage: relational databases and ADO.
Mark Dixon Page 1 17 – Persistent data storage: relational databases and ADO.
Mark Dixon, SoCCE SOFT 131Page 1 24 – Web applications: Writing data to Databases using ASP.
Mark Dixon, SoCCE SOFT 131Page 1 23 – Modular Design in ASP.
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.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: HTML and Client-side code.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
Mark Dixon, SoCCE SOFT 131Page 1 17 – Persistent data storage: relational databases and ADO.
Mark Dixon Page 1 21 – Object Oriented Programming in ASP.
1 Computing for Todays Lecture 22 Yumei Huo Fall 2006.
Mark Dixon, SoCCE SOFT 131Page 1 23 – Entity-relationship diagrams.
Mark Dixon, SoCCE SOFT 131Page 1 22 – Web applications: Writing data to Databases using ASP.
Mark Dixon, SoCCE SOFT 131Page 1 16 – Passing Data between pages: Sessions, Query Strings, & Self Posting.
Mark Dixon Page 1 18 – Persistent data storage: relational databases and ADO.
Mark Dixon Page 1 02 – Queries: Query by Example.
Mark Dixon Page 1 20 – Modular Design in ASP. Mark Dixon Page 2 Session Aims & Objectives Aims –Highlight modular design techniques in ASP Objectives,
Mark Dixon, SoCCE SOFT 131Page 1 18 – Structured Query Language.
Mark Dixon Page 1 20 – Web applications: Writing data to Databases using ASP.
Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)
Mark Dixon, SoCCE SOFT 131Page 1 19 – Web applications: Server-side code (ASP)
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: Writing data to Databases using ASP.
Figure 1. Hit analysis in 2002 of database-driven web applications Hits by Category in 2002 N = 73,873 Results Reporting 27% GME 26% Research 20% Bed Availability.
A trusted source of health service provider information Demonstration and Scenarios Press any key on any slide to continue Copyright © 2003, Province of.
Mark Dixon 1 20 – Persistent data storage: relational databases and ADO.
Mark Dixon Page 1 5 – Persistent data storage: relational databases.
Getting started on informaworld™ How do I register my institution with informaworld™? How is my institution’s online access activated? What do I do if.
Tutorial 10 Adding Spry Elements and Database Functionality Dreamweaver CS3 Tutorial 101.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
Mark Dixon Page 1 24 – Object Oriented Programming in ASP.
Mark Dixon Page 1 3 – Web applications: Server-side code (JSP)
Mark Dixon 1 22 – Web applications: Writing data to Databases using ASP.Net.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using ASP.
CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages.
Mark Dixon Page 1 18 – Web applications: Server-side code (PhP)
Mark Dixon Page 1 21 – Persistent data storage: relational databases and MySQL.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
Training Guide for Inzalo SOP Users. This guide has been prepared to demonstrate the use of the Inzalo Intranet based SOP applications. The scope of this.
Mark Dixon 1 03 – Passing Data between pages: Forms, Sessions, & Query Strings.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
Lecture Note 10: Simple Database Techniques. Introduction –Database System –Access, SQL Server and others. –Microsoft Access - Interacting with this databases.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
M Dixon 1 Tech HTML. M Dixon 2 Admin Attendance Register: –log in to your profile.
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.
Introduction to KE EMu Unit objectives: Introduction to Windows Use the keyboard and mouse Use the desktop Open, move and resize a.
Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)
Mark Dixon 1 22 – Object Oriented Programming. Mark Dixon 2 Questions: Databases How many primary keys? How many foreign keys? 3 2.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
A user guide to accessing, reviewing and contributing to the Online Registry System.
Mark Dixon, SoCCE SOFT 131Page 1 12 – Databases: Structured Query Language.
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 6: Accessing a database with PHP Rob Gleasure robgleasure.com.
18 – Databases: Structured Query Language
21 – Web applications: Server-side code (ASP)
INT213 Updating the Database.
23 – Object Oriented Programming in ASP
Setting the Permissions
17 – Persistent data storage: relational databases and ADO
Presentation transcript:

Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP

Mark Dixon Page 2 Session Aims & Objectives Aims –To introduce the fundamental ideas involved in using server-side code to write data to databases Objectives, by end of this week’s sessions, you should be able to: –create an ASP web page that allows the user to store data in database

Mark Dixon Page 3 Searching for Data Recordset methods –Find: searches for the next record to match given criteria string: e.g. "Name = 'Smith' " ( " are for VB string) ( ' are for database string)

Mark Dixon Page 4 Example: Person v1 (Specification) User requirement: –Display person’s details from database online, and be able to move to next and previous person (record) Problem: –Can’t use.MoveNext and.MovePrev recordset methods: record set does not persist between pages

Mark Dixon Page 5 Example: Person v1 (html) Person's Details Person's Details <% ' ASP code will go here (next slide). %> Self post

Mark Dixon Page 6 Example: Person v1 (ASP) <% Const adOpenDynamic = 3 Const cs = "…" Dim rs rs = CreateObject("ADODB.Recordset") rs.Open("Person", cs, adOpenDynamic ) If Session("curID") <> "" Then rs. Find ( "[ID] = " & Session("curID")) If Request.Form("btnPrev") <> "" Then rs. MovePrevious() ElseIf Request.Form("btnNext") <> "" Then rs. MoveNext() End If Session("curID") = rs.Fields("ID").Value Response.Write( rs.Fields("Surname").Value & " ") Response.Write( rs.Fields("Forenames").Value) rs.Close() rs = Nothing %> Button value empty unless button was pressed Use session variable to record current position in db

Mark Dixon Page 7 Example: Person v2 (Specification) User requirement: Display person’s details from database online, and be able to move to next and previous person (record) –Change surname and save to database

Mark Dixon Page 8 Database Permissions 1 In order for ASP to write to a database –Need to give write access to Internet Guest Account for database file (People.mdb) Right-click on file in Windows Explorer (the following screens are for Windows 2000)

Mark Dixon Page 9 Database Permissions 2 Click Security tab Click Add button

Mark Dixon Page 10 Database Permissions 3 Select Internet Guest Account IUSR_ … Click Add button Click OK button

Mark Dixon Page 11 Database Permissions 4 Select Internet Guest Account Ensure write access is on

Mark Dixon Page 12 Writing data to a database create recordset open recordset –dynamic cursor (3), pessimistic locking (3) to add a record –use to AddNew method rs.AddNew to delete a record –use the Delete method rs.Delete to change existing data –assign a new value to fields rs.Fields("Surname").Value = "Fred"

Mark Dixon Page 13 Changing Data Recordset methods –AddNew: inserts a new record and makes it current –Update: sends changes back to DB –Delete: deletes currently selected record

Mark Dixon Page 14 Example: Person v2 (html) Person's Details Person's Details <% ' ASP code will go here (next slide). %> Surname: " > PersonEdit.aspx

Mark Dixon Page 15 Example: Person v2 (ASP) <% Const cs = "…" Dim rs Dim Surname rs = CreateObject("ADODB.Recordset") rs.Open("Person", cs, 3, 3) If Session("curID") <> "" Then rs.Find("[ID] = " & Session("curID")) If Request.Form("btnPrev") <> "" Then rs.MovePrevious() ElseIf Request.Form("btnNext") <> "" Then rs.MoveNext() ElseIf Request.Form("btnSave") <> "" Then rs. Fields("Surname") = Request.Form("txtSurname") rs. Update() End If Session("curID") = rs.Fields("ID").Value Surname = rs.Fields("Surname").Value rs.Close() rs = Nothing %>

Mark Dixon Page 16 Example: Phone Book (database) Person IDSurnameForenamesPhoneNum 1DixonMark JonesSally SmithAlex

Mark Dixon Page 17 Example: Phone Book (screen)

Mark Dixon Page 18 Tutorial Exercise: Person v1 Task 1: Get the Person (v1) example from the lecture working. Task 2: Modify your code, so that all fields are displayed. Task 3: Modify your code, so that it does not generate an error when the user goes past the end or beginning of the recordset.

Mark Dixon Page 19 Tutorial Exercise: Person v2 Task 1: Get the Person (v2) example from the lecture working. Task 2: Modify your code, so that a line of text is displayed confirming that data has been saved.

Mark Dixon Page 20 Tutorial Example: Phone Book Task 1: Get the Phone Book example from the lecture working. Task 2: Add a button on your page that jumps to another page, which allows a new record to be added. Task 3: Modify your code, so that each line (record) has a link leading to another page that allows the data to be edited. Task 4: Modify your code, so that each line (record) has a link leading to another page that allows the record to be deleted.