Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: Writing data to Databases using ASP.

Slides:



Advertisements
Similar presentations
A new generation of practice management software
Advertisements

The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
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 Page 1 04 – Database Design: Forms. Mark Dixon Page 2 Session Aims & Objectives Aims –To allow easier data entry using forms Objectives, by.
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, SoCCE SOFT 131Page 1 16 – Web applications: HTML and Client-side code.
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, SoCCE SOFT 131Page 1 11 – Arrays of Structures & Modules.
Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)
Mark Dixon, SoCCE SOFT 131Page 1 19 – Web applications: Server-side code (ASP)
A trusted source of health service provider information Demonstration and Scenarios Press any key on any slide to continue Copyright © 2003, Province of.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Mark Dixon 1 20 – Persistent data storage: relational databases and ADO.
Mark Dixon Page 1 5 – Persistent data storage: relational databases.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
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.
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.
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.
XP 1 New Perspectives on XML Binding XML Data with Internet Explorer.
Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.
Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data.
Mark Dixon, SoCCE SOFT 131Page 1 02 – Dynamic HTML (client-side scripting)
M Dixon 1 Tech HTML. M Dixon 2 Admin Attendance Register: –log in to your profile.
Mark Dixon Page 1 Soft – HTML. Mark Dixon Page 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.
Mark Dixon, SoCCE SOFT 131Page 1 18 – Enumerated Data Types and Arrays of Structures.
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.
Mark Dixon, SoCCE SOFT 131Page 1 12 – Databases: Structured Query Language.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 8 1 Microsoft Office Access 2003 Tutorial 8 – Integrating Access with the.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 6: Accessing a database with PHP Rob Gleasure robgleasure.com.
Instructional Design Center Embedding Google Documents in Blackboard.
XP Creating Web Pages with Microsoft Office
18 – Databases: Structured Query Language
21 – Web applications: Server-side code (ASP)
INT213 Updating the Database.
Services Course 9/9/2018 3:37 PM Services Course Windows Live SkyDrive Participant Guide © 2008 Microsoft Corporation. All rights reserved.
Setting the Permissions
17 – Persistent data storage: relational databases and ADO
Presentation transcript:

Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: Writing data to Databases using ASP

Mark Dixon, SoCCE SOFT 131Page 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, SoCCE SOFT 131Page 3 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, SoCCE SOFT 131Page 4 Example: Person v1 (html) Person's Details Person's Details <% ' ASP code will go here (next slide). %> Self post

Mark Dixon, SoCCE SOFT 131Page 5 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, SoCCE SOFT 131Page 6 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, SoCCE SOFT 131Page 7 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, SoCCE SOFT 131Page 8 Database Permissions 2 Click Security tab Click Add button

Mark Dixon, SoCCE SOFT 131Page 9 Database Permissions 3 Select Internet Guest Account IUSR_ … Click Add button Click OK button

Mark Dixon, SoCCE SOFT 131Page 10 Database Permissions 4 Select Internet Guest Account Ensure write access is on

Mark Dixon, SoCCE SOFT 131Page 11 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, SoCCE SOFT 131Page 12 Example: Person v2 (html) Person's Details Person's Details <% ' ASP code will go here (next slide). %> Surname: " > PersonEdit.aspx

Mark Dixon, SoCCE SOFT 131Page 13 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, SoCCE SOFT 131Page 14 Example: Phone Book (database) Person IDSurnameForenamesPhoneNum 1DixonMark JonesSally SmithAlex

Mark Dixon, SoCCE SOFT 131Page 15 Example: Phone Book (screen)

Mark Dixon, SoCCE SOFT 131Page 16 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, SoCCE SOFT 131Page 17 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, SoCCE SOFT 131Page 18 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.