Web Database Programming

Similar documents
Web Database Programming

Database Programming in Tiers

Use JavaScript Files

Web Database Programming

Switch Web Event Handler

Web Editors in Limnor Studio

Create Login Form. Longflow Enterprises Ltd. Page 1

Login Manager ASPX Sample

Web Data Repeater. Web Data Repeater 2011

Login Manager Windows Form Sample

Use Arrays and Collections

Control of Row Deletion

Programming with Visual HTML Editor

Use Web Event Bubbling

Contents Introduction

Dynamic Event Handling

Windows Forms Sample Part B2. Login Manager

Use Default Form Instances

Project types supported by Limnor Studio

Image Data Binding. Save images in database An image needs large amount of storage space. Only binary variable length fields may hold images.

Use Plug-ins. Use Plug-ins 2012

SAS STUDIO. JUNE 2014 PRESENTER: MARY HARDING Education SAS Canada. Copyr i g ht 2014, SAS Ins titut e Inc. All rights res er ve d.

DbSchema Forms and Reports Tutorial

What s New in Enterprise Jeff Simpson Sr. Systems Engineer

Web Dialogue and Child Page

DbSchema Forms and Reports Tutorial

Limnor Studio User s Guide

Web API Lab. The next two deliverables you shall write yourself.

VERSION JANUARY 19, 2015 TEST STUDIO QUICK-START GUIDE STANDALONE & VISUAL STUDIO PLUG-IN TELERIK A PROGRESS COMPANY

Limnor Studio User s Guide

Step 4 Part F - How to Download a Video on YouTube and Delete a Video

Limnor Studio User s Guide

A demo Wakanda solution (containing a project) is provided with each chapter. To run a demo:

ITP 140 Mobile Technologies. Databases Client/Server

Use Webcam in Web Pages

Database Updater. Database Updater does not have a use interface, so it will appear in Extra Performers window for the page at design time:

Instructor s Notes Web Data Management Web Client/Server Concepts. Web Data Management Web Client/Server Concepts

CSCI 4000 Assignment 6

SQL Server 2008 Tutorial 3: Database Creation

CSCI 4000 Assignment 5

CSCI 4000 Assignment 4

Data Binding. Data Binding

User Guide. Web Intelligence Rich Client. Business Objects 4.1

Oracle Database 10g Express

Locate your Advanced Tools and Applications

COURSE OUTLINE: OD10267A Introduction to Web Development with Microsoft Visual Studio 2010

SSJS Server-Side JavaScript WAF Wakanda Ajax Framework

Recommended Maintenance Plan for Siriusware Clients for SQL server 2005

RAD Studio XE Datasheet

IMS Hands-on Lab - Using The New IMS Explorer To Access Your IMS Data

HTML Mashups A mashup that embeds an HTML or JavaScript based Web page directly on a screen.

Importing from Blackboard Learn Grade Center Data to Banner 9 User Learning Scenarios

DATABASE SYSTEMS. Database programming in a web environment. Database System Course, 2016

MySQL On Crux Part II The GUI Client

1. Setup a root folder for the website 2. Create a wireframe 3. Add content 4. Create hyperlinks between pages and to external websites

Using PHP with MYSQL

CS708 Lecture Notes. Visual Basic.NET Programming. Object-Oriented Programming Web Technologies and ASP.NET. (Part I) (Lecture Notes 5B)

WKA Studio for Beginners

Chapter 3. Windows Database Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Displaying XML Documents

Introduction to Web Development with Microsoft Visual Studio 2010

Execute Server Actions from Client Methods

Chapter 10. Database Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Course Folder and Files Instructions for download and use

COMP283-Lecture 6 Applied Database Management

Case Study Ecommerce Store For Selling Home Fabrics Online

USER GUIDE PowerPhoto CRM

Mastering phpmyadmiri 3.4 for

C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies. Objectives (1 of 2)

Limnor Studio Getting Started

Parse String at Web Client

If this is the first time you have run SSMS, I recommend setting up the startup options so that the environment is set up the way you want it.

.NET FRAMEWORK. Visual C#.Net

Ajax- XMLHttpResponse. Returns a value such as ArrayBuffer, Blob, Document, JavaScript object, or a DOMString, based on the value of

SQL CSCI 201 Principles of Software Development

CSCI 201 Lab 1 Environment Setup

Mysql Tutorial Show Table Like Name Not >>>CLICK HERE<<<

Web API Lab folder 07_webApi : webapi.jsp your testapijs.html testapijq.html that works functionally the same as the page testapidomjs.

Information Systems Engineering

Red Hat JBoss Fuse 7.0-TP

OpenText Gupta TD Mobile Release Notes

HALTON SKILLS COMPETITION WEBSITE DEVELOPMENT SCOPE SECONDARY LEVEL Coordinator: Ron Boyd,

Beginning ASP.NET. 4.5 in C# Matthew MacDonald

Enterprise Architect. User Guide Series. Hybrid Scripting. Author: Sparx Systems. Date: 26/07/2018. Version: 1.0 CREATED WITH

The following instructions cover how to edit an existing report in IBM Cognos Analytics.

Technology Preview. New RMAD (Rapid Mobile Application Development) Module for Convertigo Studio

IN THIS CHAPTER,YOU LEARN THE BASICS of databases, including how they

ASP.NET Web Forms Programming Using Visual Basic.NET

ASP.NET Using C# (VS2013)

TIBCO Jaspersoft running in AWS accessing a back office Oracle database via JDBC with Progress DataDirect Cloud.

CSC 330 Object-Oriented

Submitting Assignments

VS2010 C# Programming - DB intro 1

Jukebox. Sample Application - Jukebox

An introduction for the novice. David Lawrence, JLab. 5/8/07 MySQL David Lawrence 1/36

Advanced SQL. Nov 21, CS445 Pacific University 1

Kendo UI. Builder by Progress : What's New

Learn Well Technocraft

EPHP a tool for learning the basics of PHP development. Nick Whitelegg School of Media Arts and Technology Southampton Solent University

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.

Transcription:

Web Database Programming Web Database Programming 2011 Created: 2011-01-21 Last update: 2014-01-14 Contents Introduction... 2 Use EasyDataSet as Data Source... 2 Add EasyDataSet to web page... 3 Make Database Connection... 4 Use Query Builder to get data... 7 Bind-data to single field... 10 Data Query... 13 Data Search... 17 Data Navigation... 18 Modify and Save Data... 20 MySql Database Credential... 24 Test Data Entry... 25 Bind Data to Html Table... 28 Web Page Security... 33 Field Editors... 33 Data Repeater... 33 Change Query Filters at Runtime... 33 Create New Records... 33 Data Streaming... 33 Fetch Data of One-to-Many Relation... 33 Change Data-binding... 33 Feedbacks... 33 Longflow Enterprises Ltd. Page 1

Introduction Web pages can be designed as front tier for showing data from databases and entering data to be stored in databases. Limnor Studio uses two-way data-binding to simplify web database programming. Ajax is used for retrieving data from databases and sending data to databases. From visual programming point of view, using databases in a web application is very much the same as using databases in a standalone application. We create a PHP web application to show the process: In this document we only use components which can be used in both PHP and.net web applications. Therefore you may choose to select Web Application (.Net) and every operation described in this document is valid. See http://www.limnor.com/support/webapplicationdevelopment.pdf for an introduction on web application development. The contents of this document were tested on IE, Opera, Chrome, Safari, and Firefox. Use EasyDataSet as Data Source We use a Student table with following fields as our sample database. StudentId, Firstname, Lastname, BirthDate, Grade Longflow Enterprises Ltd. Page 2

We used the following Sql script to create the table in a MySql database. Create Table Student ( StudentId int not null auto_increment, Firstname nvarchar (30), Lastname nvarchar (30), BirthDate datetime, Grade int, Primary Key (StudentId) ); Or you may use some GUI tool to create and manage your MySql database. This is not in the scope of this document. Add EasyDataSet to web page We add an EasyDataSet to the web page to connect the MySql database and get data from the Student table: Note that the EasyDataSet component can be used in all kinds of applications: standalone application; PHP web applications;.net web applications. The configuration of this component is also exactly the same for all kinds of applications. If you already used EasyDataSet in standalone applications then you may skip this chapter. Longflow Enterprises Ltd. Page 3

Make Database Connection Set DatabaseConnection property of the EasyDataSet: Web Database Programming 2011 Choose Other connection type for the DatabaseType property: Choose MySql.MySqlClient.MySqlConnection. Click OK: Longflow Enterprises Ltd. Page 4

Set the connection string to connect to the MySql database: Give the connection a name: Longflow Enterprises Ltd. Page 5

Click to test the connection: Note that we are connecting the database using ADO.NET driver. This is for design time only. At runtime for PHP web applications, ADO.NET driver is not used because it may not be available in a Linux machine. PHP library for MySql database will be used. All this is done behind the scene. You, as a developer, Longflow Enterprises Ltd. Page 6

develop in the same way for web applications and for standalone applications. Limnor Studio compiler will generate PHP code for you. Note that after setting a database connection, the solution must be re-built before you can click the green arrow button to test the web pages. Use Query Builder to get data Set the SQL property of the EasyDataSet to fetch Student data: Add all the fields we want to display in the web page to the query. Click Filter button to add filters for limiting the range of data: Longflow Enterprises Ltd. Page 7

For this sample, we simply use a range of StudentId as the filter. We will let the web user to enter the range from web browser. So, we will use parameters in the filter. Select the StudentId, choose >, choose Param, and give a parameter name id1: Click Add filter. The filter appears: Longflow Enterprises Ltd. Page 8

Select <; give another parameter name id2. Click Add AND filter : For this sample, that is all we want. Click OK buttons. Longflow Enterprises Ltd. Page 9

Bind-data to single field To allow the user to do data entry we may use a text box. For displaying data only we may use a label. We use a label to display StudentId: Rename it to lblstudentid: Set its Databindings property to bind its Text to StudentId: Longflow Enterprises Ltd. Page 10

Use a text box to show and edit first name: Rename it to txtfirstname: Longflow Enterprises Ltd. Page 11

Bind its Text to the Firstname field: In the same way we may create data-bindings for other fields: To change data-binding at runtime, see chapter Change Data-binding. Longflow Enterprises Ltd. Page 12

Data Query To get data from the database, we need to execute a query action. Since we use parameters in filters, we need to build a UI to let the user to enter values for the parameters. We use two text boxes for entering id1 and id2: We use a button to trig a query: When the user clicks the button we want to execute a query. Right-click the button; choose Assign Action ; choose onclick event: Longflow Enterprises Ltd. Page 13

Select QueryWithParameterValues of the EasyDataSet; click Next: Select Property for @id1: Longflow Enterprises Ltd. Page 14

Select the Text property of the text box for starting id: For @id2, select the Text property of the text box for end id: Longflow Enterprises Ltd. Page 15

Click OK to finish creating the query action and assigning it to the button: Longflow Enterprises Ltd. Page 16

We are done creating an action and assigning it to the button. You can see it in the Event Map and Object Explorer. Data Search EasyDataSet has a method Search for searching data fetched from database: Longflow Enterprises Ltd. Page 17

There are huge differences between a Search action and a Query action. A Query action searches data in the database and downloads found data to web page. A Search action searches among the data downloaded from the database; the found record becomes the current record. To do a Search, a Query action must be executed first to fetch data from the database server. Data Navigation On fetching a range of student records, we may use go next, go previous, go first and go last actions to navigate through the records. We add 4 buttons for this purpose: Longflow Enterprises Ltd. Page 18

Let these buttons trig actions. Right-click button < ; choose Assign Action ; choose onclick event: Choose MoveFirst from the EasyDataSet; click Next: Click OK to finish creating the action and assigning the action to the event: Longflow Enterprises Ltd. Page 19

Do the same for the other 3 buttons and use MovePrevious, MoveNext and MoveLast respectively. Modify and Save Data We may use a button for adding new record and a button for removing the current record. Right-click Add student button; choose Assign Action ; choose onclick event: Longflow Enterprises Ltd. Page 20

Choose AddNewRecord and click Next: Click OK to finish creating the action and assigning it to the event: Right-click button Delete ; choose Assign Action ; choose onclick event: Longflow Enterprises Ltd. Page 21

Choose DeleteCurrentRecord ; click Next: Click OK to finish creating the action and assigning it to the event: One click of the Add student button will add one new student record on the page. Click the Delete button will remove the current record from the page. Typing in the text boxes will modify the student data on the page. Longflow Enterprises Ltd. Page 22

Note that all the modifications are kept only in the web page. Nothing is changed in the database. To save all the modifications kept in the page to the database, we need to execute an Update action. We use a Save button to trig such an action. Right-click the Save button; choose Assign Action ; choose onclick event: Choose Update ; click Next: Click OK to finish creating the action and assigning it to the event: Longflow Enterprises Ltd. Page 23

We have all the buttons triggering actions executed by the EasyDataSet: MySql Database Credential Compile the project. All web files are generated under WebFiles folder. The credential for MySql database is in a file named mysqlcredential.php in the libphp folder: You may edit this page to set the credential for you database. Longflow Enterprises Ltd. Page 24

You edit the PHP code in the above file to provide MySql credential in a variable named $cr. The file will not be overwritten by the compiler if you modify it. Test Data Entry Let s turn on DebugMode so that we may watch client/server communications and watch for any errors: Start debugging: Longflow Enterprises Ltd. Page 25

Enter id range and click Query database to get data: We ll see empty data if no records are found in the id range: Longflow Enterprises Ltd. Page 26

Click Add student button. Enter some data in the text boxes. Longflow Enterprises Ltd. Page 27

You may click Add student many times to add many students. You may click the navigation buttons <, <, > and > to go through the students. You may also click Delete button to remove the student record currently displayed on the page. After making all the changes, click Save button to save the data to the database. From the debugging information, we can see that how many records are added; how many records are deleted and how many records are modified: We may close the web page and re-open it. Set the id range and click Query database button. Now we will see student records we just entered. It proves that the data we entered have been saved in the database. Bind Data to Html Table Records from a database can be bound to a HTML table for displaying and editing. Drop an HtmlTable to the web page: Longflow Enterprises Ltd. Page 28

Set its DataSource property to EasyDataSet1: Run the project: Longflow Enterprises Ltd. Page 29

Query the database by clicking the Query database button: The data appears in the html elements: Longflow Enterprises Ltd. Page 30

The highlighted row of the html table indicates the current record of the data. The user may click a row in the html table to make it the current record. Let s click the second row: Longflow Enterprises Ltd. Page 31

The user may click a cell in the html table to edit the data in the cell. Let s click the Grade cell of the second row: Longflow Enterprises Ltd. Page 32

Web Page Security See http://www.limnor.com/support/webdatabaseprogramming2.pdf Web Database Programming 2011 Field Editors See http://www.limnor.com/support/webdatabaseprogramming3.pdf Data Repeater In chapter Bind-data to single field, we saw that a form can be designed with data-bound controls. Data from database are automatically displayed on the controls. The user may modify data on the controls and the data modifications can be saved back to database. In such arrangement, one record is displayed on one web page. Data Repeater allows you to design the form with data-bound controls, but the same design can be repeated on one web page. Thus many records can be displayed on one web page. For details, see http://www.limnor.com/support/webdatarepeater.pdf Change Query Filters at Runtime See http://www.limnor.com/support/webdatabaseprogramming4.pdf Create New Records See http://www.limnor.com/support/webdatabaseprogramming5.pdf Data Streaming See http://www.limnor.com/support/webdatabaseprogramming5.pdf Fetch Data of One-to-Many Relation See http://www.limnor.com/support/webdatabaseprogramming5.pdf Change Data-binding See http://www.limnor.com/support/webdatabaseprogramming5.pdf Feedbacks Please send your feedbacks to support@limnor.com, thanks! Longflow Enterprises Ltd. Page 33

Longflow Enterprises Ltd. Page 34