Database Communica/on in Visual Studio/C# using 3- /er Arcitecture

Similar documents
Database Communica/on in Visual Studio/C# using Web Services. Hans- Pe=er Halvorsen, M.Sc.

Database Communica/on in Visual Studio/C# using ASP.NET Web Forms. Hans- PeBer Halvorsen, M.Sc.

Create Installa+on Packages in Visual Studio

Web Services. with Examples. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics

Cloud-based Data Logging, Monitoring and Analysis

VB.NET - DATABASE ACCESS

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

How To Create A Database In Araba

Create a Virtual Test Environment

BACKING UP A DATABASE

Lab Inventory System. Label Writer Access Card with Barcode Barcode Reader. Hans- Pe(er Halvorsen, M.Sc.

5 Airport. Chapter 5: Airport 49. Right-click on Data Connections, then select Add Connection.

SQL Desktop Application For WebService in C# dr inż. Tomasz Tatoń

EXAM PRO:Design & Develop Windows Apps Using MS.NET Frmwk 4. Buy Full Product.

Conexión SQL Server C#

So#ware Development. Overview. Hans- Pe4er Halvorsen, M.Sc. h4p://home.hit.no/~hansha/?page=so#ware_development

Hunk & Elas=c MapReduce: Big Data Analy=cs on AWS

Programming in C# with Microsoft Visual Studio 2010

Course 10978A Introduction to Azure for Developers

Developing ASP.NET MVC 4 Web Applications Course 20486A; 5 Days, Instructor-led

Crystal Reports for Visual Studio.NET

ASP.NET Programming with C# and SQL Server

MS 10978A Introduction to Azure for Developers

Working with Data in ASP.NET 2.0 :: Creating Stored Procedures and User Defined Functions with Managed Code Introduction

TechTips. Connecting Xcelsius Dashboards to External Data Sources using: Web Services (Dynamic Web Query)

SQL injection attacks SQL injection user input SQL injection SQL Command parameters Database account. SQL injection attacks Data Code

ADOBE READER AND ACROBAT

Microsoft Dynamics Training

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

GoDaddy (CentriqHosting): Data driven Web Application Deployment

Developing Microsoft Azure Solutions 20532B; 5 Days, Instructor-led

About the Authors About the Technical Reviewer

10978A: Introduction to Azure for Developers

MS Enterprise Library 5.0 (Logging Application Block)

Getting Started with Telerik Data Access. Contents

Laboratory Inventory System

Getting Started with Elastic DB Database Tools with Azure SQL

Deploying Web Applications in Enterprise Scenarios

Client/server is a network architecture that divides functions into client and server

Web. Programming. Hans- Pe0er Halvorsen, M.Sc. h0p://home.hit.no/~hansha/?page=sojware_development

This module provides an overview of service and cloud technologies using the Microsoft.NET Framework and the Windows Azure cloud.

João Diogo Almeida Premier Field Engineer Microsoft Corporation

CATALOG OF CLASSES IT and Technical Courses

ASP.NET. Web Programming. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics

ICONICS Using the Azure Cloud Connector

How to set up SQL Source Control. The short guide for evaluators

How To: Create a Crystal Report from ADO.NET Dataset using Visual Basic.NET

System Center 2012 R2 SP1 Configuration Manager & Microsoft Intune

SQL Server 2005 Reporting Services (SSRS)

Visual Basic. murach's TRAINING & REFERENCE

USER GUIDE Appointment Manager

LMS. OSI Layers and the Learning Management System. Over view

Developing ASP.NET MVC 4 Web Applications

Analytics Configuration Reference

HTML5. Turn this page to see Quick Guide of CTTC

Database Systems. S. Adams. Dilbert. Available: Hans-Petter Halvorsen, M.Sc.

Introduction to Azure for Developers

ASP and ADO (assumes knowledge of ADO)

Practical Database Programming With Visual C#.NET

The So5ware Development Process (SDLC)

A Tutorial on SQL Server CMPT 354 Fall 2007

CLOUD COMPUTING & WINDOWS AZURE

1.Tüm Kayıtları Getirme - Arama Yapma

Visual COBOL ASP.NET Shopping Cart Demonstration

listboxgaatmee.dragdrop += new DragEventHandler(listBox_DragDrop); ListBox from = (ListBox)e.Data.GetData(typeof(ListBox));

SCADA, OPC and Database Systems

Dynamic Web Programming BUILDING WEB APPLICATIONS USING ASP.NET, AJAX AND JAVASCRIPT

An Evaluation of No-Cost Business Intelligence Tools. Claire Walsh

Rainer Stropek time cockpit. NuGet

Microsoft Introduction to Azure for Developers

INTERNET PROGRAMMING AND DEVELOPMENT AEC LEA.BN Course Descriptions & Outcome Competency

2311A: Advanced Web Application Development using Microsoft ASP.NET Course 2311A Three days Instructor-led

CP003 Azure SQL Database V12 updates and comparison with SQL Server

General principles and architecture of Adlib and Adlib API. Petra Otten Manager Customer Support

INTEGRATING MICROSOFT DYNAMICS CRM WITH SIMEGO DS3

Using IRDB in a Dot Net Project

MS 20487A Developing Windows Azure and Web Services

Creating Form Rendering ASP.NET Applications

COMMON All Day Lab 10/16/2007 Hands on VB.net and ASP.Net for iseries Developers

Kentico CMS 7.0 Windows Azure Deployment Guide

Catálogo de cursos plataforma elearning Microsoft Imagine Academy: Microsoft SQL Server y Visual Studio

So#ware Deployment. Hans- Pe4er Halvorsen, M.Sc. h4p://home.hit.no/~hansha/?page=so#ware_development

Programming. Languages & Frameworks. Hans- Pe(er Halvorsen, M.Sc. h(p://home.hit.no/~hansha/?page=sodware_development

How to test and debug an ASP.NET application

Kaseya Fundamentals Workshop DAY THREE. Developed by Kaseya University. Powered by IT Scholars

Creating the Product Catalog Part I (continued)

Chapter 3. Database Architectures and the Web Transparencies

Deploying Migrated IBM Notes Applications to the Cloud

Microsoft Azure - Week6 Tuesday -

Data Logging and Monitoring Pro. Hans-Petter Halvorsen, M.Sc.

SQL Server Database Web Applications

Course 5431: Getting Started with Microsoft Office PowerPoint Course 5420: Editing and Proofreading Documents in Microsoft Office Word 2007

Quartz.Net Scheduler in Depth

How to start creating a VoIP solution with Ozeki VoIP SIP SDK

Installing the ASP.NET VETtrak APIs onto IIS 5 or 6

Walkthrough: Creating and Using an ASP.NET Web Service in Visual Web Developer

Silect Software s MP Author

Apprenda.NET Developer Tutorial

ITDUMPS QUESTION & ANSWER. Accurate study guides, High passing rate! IT dumps provides update free of charge in one year!

Transcription:

Database Communica/on in Visual Studio/C# using 3- /er Arcitecture The examples uses ADO.NET Hans- Pe=er Halvorsen, M.Sc.

The database- centric style. Typically, the clients communicate directly with the database. A three- /er style, in which clients do not connect directly to the database. Web Services, etc. 2

3- /er/layer Architecture Note! The different layers can be on the same computer (Logic Layers) or on different Computers in a network (Physical Layers) Presenta/on Tier Business Logic Tier Data Access Tier Data Source PL BL DAL Data Tier - DL Logic Tier 3

Why 3- Tier (N- Tier Architecture?) Flexible applica/ons Reusable code Code once, use many /mes Modularized You need only to change part of the code You can deploy only one part You can Test only one part Mul/ple Developers Different parts (Tiers) can be stored on different computers Different PlaYorms and Languages can be used etc. 4

h=p://en.wikipedia.org/wiki/mul//er_architecture 5

3- /er/layer Architecture Presenta4on Tier This is the topmost level of the applica/on. The presenta/on /er displays informa/on related to such services as browsing merchandise, purchasing and shopping cart contents. It communicates with other /ers by which it puts out the results to the browser/client /er and all other /ers in the network. In simple terms it is a layer which users can access directly such as a web page, or an opera/ng systems GUI Applica4on 4er (business logic, logic 4er, data access 4er, or middle 4er) The logical /er is pulled out from the presenta/on /er and, as its own layer. It controls an applica/on s func/onality by performing detailed processing. Data 4er This /er consists of database servers. Here informa/on is stored and retrieved. This /er keeps data neutral and independent from applica/on servers or business logic. Giving data its own /er also improves scalability and performance. h=p://en.wikipedia.org/wiki/mul//er_architecture 6

3- /er Architecture Presenta/on Tier Presenta/on Tier Presenta/on Tier Different Devices can share the same Business and Data Access Code Business Logic Tier Data Access Tier Logic Tier The different Tiers can be physical or logical Stored Procedures Database Data Tier

3- /er + WebService Architecture - Example Installed on one or more Windows Servers in your LAN or in the Cloud Team Founda/on Server TFS Cient Web Server Web Services Business/ Data Logic Tier Data Source Stored Procedures Data Tier Team Founda/on Server Presenta/on Tier 8

3- /er Architecture Scenarios Client Client Internet Client Firewall Presenta/on Layer Presenta/on Layer Presenta/on Layer Client Client Web Service Presenta/on Layer Server Presenta/on Layer Local Network (LAN) Presenta/on Layer Business Logic Web Server Server Database Stored Procedures Data Access Logic

Crea/ng the Data Tier Hans- Pe=er Halvorsen, M.Sc.

Data Tier We are going to create the Database / Data Layer/Tier, including: 1. Tables 2. Views 3. Stored Procedures 4. Triggers 5. Script for some Dummy Data Note! Install them in this order Download Zip Files with Tables, Views, Stored Procedures and Triggerse in order to create the Data Tier in SQL Server (The ZIP File is located on the same place as this File) 11

Data Tier Triggers Stored Procedures Views Tables Data Tier SQL Server 12

Database Tables 13

Execute the different Scripts inside SQL Server Management Studio 14

You are finished with the Exercise 15

Crea/ng the Logic Tier Hans- Pe=er Halvorsen, M.Sc.

Logic Tier ASP.NET Web Forms Presenta/on Tier WinForms Presenta/on Tier Windows Store App Presenta/on Tier Logic Tier Purpose: All the Apps should/could share the same Logic Tier To make your Apps easier to maintain and extend etc. Data Tier Database 17

Create an Empty (Blank) Solu4on in Visual Studio 18

Add Project for Logic Tier (Data Access) Select a Class Library Project LogicTier 19

Add a New Class to the Project ( StudentData.cs ) StudentData.cs 20

Create the Code, e.g., like this ( StudentData.cs ): Create your own Namespace A View that collects data from several tables Improvements: Use Try... Catch... 21

You should test the SQL Query in the SQL Server Management Studio first 22

Code ( StudentData.cs ): using System.Data.SqlClient; using System.Data.SqlTypes; using System.Data; namespace Tuc.School.LogicTier { public class StudentData { public DataSet GetStudentDB(string connectionstring) { string selectsql = "select StudentName, StudentNumber, SchoolName, ClassName, Grade from StudentData order by StudentName"; // Define the ADO.NET objects. SqlConnection con = new SqlConnection(connectionString); SqlDataAdapter da = new SqlDataAdapter(selectSQL, con); DataSet ds = new DataSet(); da.fill(ds); return ds; } } } 23

Create a proper name for the Assembly (.dll File) Right- click on the Project in the Solu/on Explorer and select Proper/es Then Build your Project (hopefully with no errors) This will be the Assembly for your Logic Tier, that can be imported and used in other projects. Create once use it many /mes!! 24

You are finished with the Exercise 25

Crea/ng the Presenta/on Tier Hans- Pe=er Halvorsen, M.Sc.

Presenta/on Layer Desktop App: WinForms We assume the App will be used only in the local LAN (or local on the same computer where the database is located) and that we have direct access to the Database) Label DataGridView 27

Add a WinForm Project 28

Add a New Class ( StudentWinForm.cs ) 29

Add Code in Class Add a Reference to the Assembly in the Logic Tier 30

Code for Class StudentWinForm.cs using System.Data; using Tuc.School.LogicTier; Since we are using the DataSet Class Reference to our Logic Tier namespace Tuc.School.WinFormApp { class StudentWinForm { public DataSet GetStudent(string connectionstring) { StudentData studentdata = new StudentData(); } return studentdata.getstudentdb(connectionstring); } } Our Database Method in our Logic Tier 31

Create Form Label DataGridView 32

Create Form Code 33

WinForm Code using System.Configuration; using Tuc.School.WinFormApp; namespace WinFormApp { public partial class Form1 : Form { Note! Connec/onString is stored in App.config private string connectionstring = ConfigurationManager.ConnectionStrings["SCHOOLConnectionString"].ConnectionString; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { FillStudentGrid(); } private void FillStudentGrid() { DataSet ds = new DataSet(); StudentWinForm studentlist = new StudentWinForm(); ds = studentlist.getstudent(connectionstring); datagridviewstudentinformation.datasource = ds.tables[0]; } } } 34

Note! Add System.Configura/on Reference 35

Create DB Connec/onString in App.config <?xml version="1.0" encoding="utf- 8"?> <configuration> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.5" /> </startup> <connectionstrings> <add name="schoolconnectionstring" connectionstring="data Source=macwin8;Initial Catalog=SCHOOL;Persist Security Info=True;User ID=sa;Password=xxxxxx" providername="system.data.sqlclient" /> </connectionstrings> </configuration> 36

Test it It works!!! 37

You are finished with the Exercise 38

Recommended Li=erature Tutorial: Introduc/on to Database Systems h=p://home.hit.no/~hansha/?tutorial=database Tutorial: Structured Query Language (SQL) h=p://home.hit.no/~hansha/?tutorial=sql Tutorial: Using SQL Server in C# Tutorial: Introduc/on to Visual Studio and C# h=p://home.hit.no/~hansha/?tutorial=csharp 39

Hans- PeUer Halvorsen, M.Sc. Telemark University College Faculty of Technology Department of Electrical Engineering, Informa4on Technology and Cyberne4cs E- mail: hans.p.halvorsen@hit.no Blog: hup://home.hit.no/~hansha/ 40