Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET...

26
Craig Pelkie [email protected] Copyright © 2014, Craig Pelkie ALL RIGHTS RESERVED Getting Started with Microsoft .NET for IBM i Developers

Transcript of Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET...

Page 1: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Craig [email protected]

Copyright © 2014, Craig PelkieALL RIGHTS RESERVED

Getting Started withMicrosoft .NET

for IBM i Developers

Page 2: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

What does the .NET Framework “buy you”?

• Comprehensive development environment• Many commonly needed resources are built into the framework

• Windows programming• Web programming• Web services• Database• XML

• Consistent object model• The .NET Framework is supplied / supported by Microsoft

• Commonly used base data types, low-level code• Supporting classes• Exception handling

2

Page 3: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Microsoft Programming Languages for .NET

• C++• Primary development language for most Windows system programming• Can be used in .NET environment

• F#• Functional Language• See wikipedia.org article, “F Sharp (programming language)”

• Visual Basic• Long history as an easy-to-use, applications-oriented tool• Visual Basic.NET: completely new version of language• Is a full O-O programming language with complete access to

the .NET environment

• C# (C-sharp)• New language, introduced with .NET• Characteristics of C, C++, Java

3

Page 4: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Factors to Consider

• Most RPG programmers are more comfortable with Visual Basic

• Programmers with Java / C experience will be more comfortable with C#

• Biggest Factor• As you get up-to-speed with .NET development

• The "fear" of the language is less emphasized• Knowledge of and usage of .NET Framework classes moves to

the foreground

4

The Language

.NET

Time / Experience The Language

.NET

Page 5: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Tools for Application Development

• .NET 4.5• Framework supports Web, Windows, Database, other commonly

required features• Supports many programming languages, most popular:

C#, Visual Basic• No-charge download (run-time environment, tools, compilers)

• Visual Studio• Current version is Visual Studio 2013• Several editions

• Express Editions (VB, C#, Web)• Professional Edition (includes all languages/features)

• “The 3 W's”• WCF — Windows Communication Foundation• WPF — Windows Presentation Foundation• WF — Windows Workflow Foundation

5

Page 6: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Development Environment – Visual Studio

Obtaining Microsoft Visual Studio products

Visual Studio 2013 Professional Edition – 90 Day Trialhttp://www.visualstudio.com/downloads/download-visual-studio-vs

Visual Studio Express 2013

No-charge downloads30 day trialRequires registration for continued use

6

Page 7: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Platform to Platform

7

IBM i .NET

MessagingWeb Services / WCF

WebSphere MQ – MSMQData Queues

Messaging

ProgramsStored Procedures

OLE DBAPI (cwbx)

Programs

Database.NET Provider

OLE DB ProviderODBC

Database

File System FTPNetwork Drive File System

Page 8: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Connection Options from .NET to IBM i

• The problem, in a nutshell:

• Database is on IBM i

• .NET applications need to access the data• Extensive support in .NET Framework for database• Built-in support for SQL Server, Oracle

• .NET to IBM i – Database Providers

• Components that are designed for .NET or can be used within .NET

• Handle database specific issues• EBCDIC conversion• Packed/Zoned• Access to metadata

8

Page 9: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Connection Options, IBM i Access for Windows

• IBM i Access for Windows

• Licensed Program Products

• 57xx-XW1 – IBM i Access Family

• 57xx-XE1 – IBM i Access for Windows

• These providers are no-chargecomponents of IBM i Access

• Can be installed independentlyof other IBM i Accesscomponents

Provider System i Access VRM

ODBC V5R1+OLE DB V5R1+.NET V5R3+

9

Page 10: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Notes about System i Access Providers

• ODBC, OLE DB

• No special considerations

• Accessed through .NET classes in• System.Odbc• System.OleDb

• Not the preferred providers for .NET applications

• .NET Data Provider

• Available starting at System i Access V5R3M0

• Can connect to down-level OS/400 versions

• Must have .NET Framework already installed on PC

• Not automatically installed when upgrading System i Access, must use Selective Install option

• Critically important to update to current IBM Service Pack

10

Page 11: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Data Reader Example - Visual Basic

'create the connection object to connect to iSeries

Dim cn As New iDB2Connection("DataSource=host_name")cn.Open()

'create a command object and initialize it to a valid SQL statement

Dim cmd As New iDB2Command("select * from library_name.qcustcdt", cn)

'create a data reader object, fill it by executing the command

Dim dr As iDB2DataReaderdr = cmd.ExecuteReader()

'iterate over the data reader, write out values for each row/column

While (dr.Read())

Dim I As Integer

For I = 0 To dr.FieldCount – 1

Console.Write(dr.GetName(i))

Console.Write(":" & vbTab)

Console.WriteLine(dr.GetValue(i))

Next

Console.WriteLine("-------------------------------------")End While

11

FieldCount – actual numberof fields returned in SELECT

FieldCount – 1 : upper limit of loop (counter starts at zero)

Page 12: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Data Reader Example - C#

// create the connection object to connect to iSeries

iDB2Connection cn = new iDB2Connection("DataSource=host_name");cn.Open();

// create a command object and initialize it to a valid SQL statement

iDB2Command cmd = new iDB2Command("select * from library_name.qcustcdt", cn);

// create a data reader object, fill it by executing the command

iDB2DataReader dr;dr = cmd.ExecuteReader();

// iterate over the data reader, write out values for each row/column

while (dr.Read()) {

for (int i = 0; i < dr.FieldCount; i++) {

Console.WriteLine("{0}:\t{1}",dr.GetName(i),dr.GetValue(i));

}

Console.WriteLine(new String('-', 50));}

12

FieldCount – actual numberof fields returned in SELECT

i < FieldCount : upper limit of loop (counter starts at zero)

Page 13: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Microsoft Web Development

• Based on ASP.NET• Early web technology (pre-.NET): Active Server Pages (ASP)• Mix of HTML / CSS / VBScript or JScript

• .NET Framework 1.0• Introduction of ASP.NET• Separation of presentation / code ("code behind")• Many server-side controls to generate HTML• Visual Basic or C#

• ASP.NET MVC• Introduced in .NET 3.x timeframe• "3-tier" web development environment• More oriented towards HTML/JavaScript/CSS• "Razor" syntax (inline substitution variables)

13

Page 14: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Web Development in Visual Studio 2010

14

Page 15: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Web Development in Visual Studio 2010

15

Page 16: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Display data with the GridView control

16

The GridView control is included in the Datasection of the Toolbox

The GridView is bound to a datasource toget data to display

Page 17: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Visual Studio Toolbox for Web Development

17

The Toolbox is typically displayed on the left side of Visual Studio.

You drag-and-drop a tool onto the design surface.

You set properties at design-time or in your code.

Page 18: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Develop a Web Service in Visual Studio

18

Page 19: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Web Services code to return data

19

SelectCustomer web method

Input: customer #

Output: DataSet (record) forthe customer

Page 20: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Output of the Web Service that returns data

20

Page 21: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Consume a Web Service in Visual Studio

21

In a project, useAdd Service Reference

1

2

3

45

Page 22: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Consume a Web Service in Visual Studio

22

Page 23: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Deploying .NET applications for the IBM i

23

DB2 UDBMicrosoft .NET Server

W2012 / W2008 / W2003

Development PC

VS2013

IBM i AccessOLE DB / .NET

Provider

DevelopmentBuilt-inIIS Express

IIS 6 / 7 / 7.5 / 8(web application)

IBM i AccessOLE DB / .NET

Provider

IBM i Server

Deploy fromVisual Studio

Web Users

Page 24: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Deploying .NET applications for the IBM i

• .NET applications are deployed on a Windows Server system that hosts the IIS Web Server

• Microsoft Windows 2012 / 2008 R2 server / Windows 2008• Microsoft Windows 2003 R2 Server

• Can be deployed on:• Windows XP Professional• Windows Vista Business / Windows Vista Ultimate• Windows 7 Professional +

• Visual Studio is usually not installed on a production server

• May need to obtain / install .NET Framework run-time environment for the server

• Available from Microsoft Update web site• .NET Framework (2.0, 3.0, 3.5, 4.0, 4.5)

24

Page 25: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Deploying .NET applications for the IBM i

• Microsoft .NET web applications run under

Microsoft Internet Information Services 6.0 (W2003) 7.0 / 7.5 (W2008/2008R2)8.0 (W2012)

• To do: become familiar with IIS configuration

• Copy/Publish all files for your Web application from development PC to the server (Visual Studio Publish Web Site tool)

• Reference web site: www.iis.net

• The IBM IBM i Access provider(s) must be installed on the Windows Server

• OLE DB provider and/or .NET provider

• Install the current IBM i Access Service Pack• Perform periodic IBM i Access Service Pack installs on server

• Verify that Service Pack levels on the development PC and the server are the same before deploying an application

25

Page 26: Getting Started with Microsoft .NET for IBM i · PDF fileGetting Started with Microsoft .NET for IBM i Developers. ... • Available from Microsoft Update web site • .NET Framework

Resources

www.microsoft.com/visualstudio

www.microsoft.com/net

www.iprodeveloper.comMicrosoft .NET for IBM i Developers

Track 1 - Getting Started (VS, DB providers, language [VB, C#]Track 2 - ASP.NET Web DevelopmentTrack 3 - ASP.NET and WCF Services

26

iProDeveloper eLearning course

Begins Wednesday March 26, 2014

Exclusive discount for User Group members

http://iprodeveloper.com/microsoft-net-ibm-i-developers-track-1-exclusive-discount?promo=EP14609