Introduction to Web Access to Databases

42 slides
0.8 MB

Similar Presentations

Presentation Transcript


Computer Science 101 Web Access to Databases Overview of Web Access to Databases


Why web access to database?Provides platform independent, remote access to the database Viewing data Gathering data Updating data


Client-Server TechnologiesServer: A program that provides services to other programs. It stands ready for requests and when it gets a request, it provides the service. Client: A program requesting a service of a server program. It makes a request, gets the service, and makes use of it.


Web Browsers and ServersWeb server - This is a program that runs on the internet host computer (server). It takes requests for web pages from clients and delivers the pages back to the client. Web browser - This is a program that runs on your local PC (client). It allows you to request web pages from an internet host.


HTML and HTTPHyperText Markup Language - Allows “marking up” a document with tags specifying appearance and structure. HyperText Transfer Protocol - Protocol used for browsers to communicate with web servers. Basically, this consists of “requests” from the browser and “responses” from the server.


Typical HTTP Request


Typical HTML RequestClient Side (Browser) Issues request for HTML page Receives response HTML page Interprets HTML and creates web page Displays web page Work is done here Server Side Reads request from client Finds page on server Sends response page to client Essentially a file server


Scripting LanguagesScripting languages - Allow us to add capability to what’s provided by HTML. Allow parts of the page to be built “on the fly”. These scripts are “interpreted” as they run rather than being compiled. Client-side scripts - Script engine on client machine builds parts of page when page is loaded by browser (date is simple example). Javascript is prime example. Server-side scripts - Script engine on server builds parts of page before sending to client (database query results for example). ASP, PHP, JSP, Purl are examples.


Server Side ProgramsHere we have compiled programs that run on the server. Examples could be Java Servlets, ASP.NET languages such as C#


Typical Server-Side Request


Typical Server-Side RequestClient Side (Browser) Issues request for HTML page Receives response HTML page Interprets HTML and creates web page Displays web page Server Side Reads request from client Finds page on server Runs server-side program needed Alters HTML file Sends response page to client


Web Access of DatabaseThe database resides on the server. Web pages with scripts (or calls to programs) allow the user to send database requests to the server. The server accesses the database to honor the requests. Results can be returned on an html page. Actions can take place on the database.


So, what are the pieces we need?Browser software on user machines A machine for the server Web server software on server Database management system on server Scripting/programming language for accessing the database – something supported by the web server


Web Applications: 3-Tier ArchitectureUser InterfaceApplication Logic - ProgramDatabase


The Big Picture – User InterfaceUser Interface contains web components for user input or for displaying information returned from the database. Two types of components that we will use for displaying data in our examples will be GridViews and DropDownLists. GridViews provide row and column displays. They can be configured for really nice appearance, paging, etc. These components can have associated with them a data source – essentially a database query. We’ll keep it simple.


The Big Picture – Middle TierThe middle tier has program code to get users input, connect to the database, present request to the database, get results from the database, send results on to the interface. This is where the server side programming code would come in.


The Big Picture – DatabaseDatabase receives requests in form of SQL statements or in form of request for stored query, performs the query and returns results to middle tier. You are already expert at this part, correct?


SQL Injection


SQL Injection


Simple model – retrieving and displaying data from the databaseFor now we are going to consider examples where we want the web page just to display information resulting from a query to the database. We’ll see that Visual Web Developer is very helpful with setting up connections to database, “binding” web components to data sources, etc.


Example1 – Faculty InformationAs a first example, let’s have a web page with a data grid displaying the faculty information – LastName, FirstName, Phone extension, and email address. So we would Start Visual Web Developer Open our website Create a new file (webform)


Example1 – Faculty Information (cont.)After placing any heading or whatever on the page, we drag a GridView onto the page from the Data Section of the ToolBox.


Example1 - Choosing the data source for the GridViewNew data sourceAccess DatabaseBrowse for database


Example1 - Setting up the query


Example1 - Testing the query

Browse More Presentations

Last Updated: 8th March 2018

Recommended PPTs