Introduction to AS400 Programming Using .NET
page 3 of 5
by Nidal Arabi
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 36745/ 50

Solution

Let us start with the DB2 AS400 part. It is recommended that you have client access express installed on your PC and be able to access AS400 trough the IBM ISeries navigator or through 5250 terminal. However, you should be able to connect through a simple telnet client program provided with Microsoft Windows.

After you log on to your AS400 machine, you should be able to create a library for our tests (I prefer to call this library TESTNET). Whatever you choose as a name, make sure you remember it for replacing purposes.

After creating the library, access the SQL/400 command window through STRSQL.

Listing 1 - Create Table Listing

/* Creating table TESTNET.TBLDEPT */
CREATE TABLE TESTNET.TBLDEPT 
( DEPTID INTEGER NOT NULL , DEPTNM VARCHAR (30) NOT NULL , UNIQUE (DEPTID)  ) ;

Listing 2 - Insert Procedure

CREATE PROCEDURE TESTNET.INSDEPT ( 
      IN P_ID INTEGER , 
      IN P_DESC VARCHAR(30) ) 
      LANGUAGE SQL 
      SPECIFIC TESTNET.INSDEPT 
      NOT DETERMINISTIC 
      MODIFIES SQL DATA 
      CALLED ON NULL INPUT 
      INSERT INTO TESTNET . TBLDEPT 
      ( DEPTID , DEPTNM ) VALUES ( P_ID , P_DESC )  ; 
  
COMMENT ON SPECIFIC PROCEDURE TESTNET.INSDEPT 
      IS 'INSERT DEPARTMENT' ;

Listing 3 - Update Procedure

CREATE PROCEDURE TESTNET.UPDDEPT ( 
      IN P_ID INTEGER , 
      IN P_DESC VARCHAR(30) ) 
      LANGUAGE SQL 
      SPECIFIC TESTNET.UPDDEPT 
      NOT DETERMINISTIC 
      MODIFIES SQL DATA 
      CALLED ON NULL INPUT 
      UPDATE TESTNET . TBLDEPT 
      SET DEPTNM = P_DESC 
      WHERE DEPTID = P_ID  ;

Listing 4 - Delete Procedure

CREATE PROCEDURE TESTNET.DELDEPT ( 
      IN P_ID INTEGER ) 
      LANGUAGE SQL 
      SPECIFIC TESTNET.DELDEPT 
      NOT DETERMINISTIC 
      MODIFIES SQL DATA 
      CALLED ON NULL INPUT 
      DELETE FROM TESTNET . TBLDEPT 
      WHERE DEPTID = P_ID  ; 
  
COMMENT ON SPECIFIC PROCEDURE TESTNET.DELDEPT 
      IS 'DELETE DEPARTEMENT' ;

Listing 5 - Select All Procedure

CREATE PROCEDURE TESTNET.SELDEPT ( ) 
      DYNAMIC RESULT SETS 1 
      LANGUAGE SQL 
      SPECIFIC TESTNET.SELDEPT
      NOT DETERMINISTIC 
      READS SQL DATA 
      CALLED ON NULL INPUT 
      BEGIN 
DECLARE DEPTCUR CURSOR FOR SELECT * FROM TESTNET. TBLDEPT ; 
OPEN DEPTCUR; 
END  ; 
  
COMMENT ON SPECIFIC PROCEDURE TESTNET.SELDEPT
IS 'DEPARTEMENT' ;

Listing 5 - Select By Department Id

CREATE PROCEDURE TESTNET.SDEPTID (IN P_ID INTEGER ) 
      DYNAMIC RESULT SETS 1 
      LANGUAGE SQL 
      SPECIFIC TESTNET.SDEPTID
      NOT DETERMINISTIC 
      READS SQL DATA 
      CALLED ON NULL INPUT 
      BEGIN 
DECLARE DEPTCUR CURSOR FOR SELECT * FROM TESTNET. TBLDEPT  WHERE P_ID = DEPTID; 
OPEN DEPTCUR; 
END  ; 
COMMENT ON SPECIFIC PROCEDURE TESTNET.SDEPTID
IS 'DEPARTEMENT BY ID';

Let us move to the .NET part. The programmer should have ISeries Client Access for Windows CD in order to be able to install the .NET driver. After launching the setup, select add/remove and select .NET Data provider if not selected and complete the installation.

First, you should download and install the .NET Driver for AS400 DB2. Once you have finished, you are ready to start following the step-by-step instructions to create your ASP.NET page for this code table.


View Entire Article

User Comments

Title: 2012 NFL jerseys   
Name: NIKE NFL jerseys
Date: 2012-05-20 11:33:23 PM
Comment:
[/pre]Cheap NFL,NBA,MLB,NHL
[url=http://www.jersey2shop.com/]Jerseys From China[/url]
[url=http://www.jersey2shop.com/]2012 nike nfl Jerseys[/url]
[url=http://www.jersey2shop.com/]cheap China Jerseys[/url]
[url=http://www.jersey2shop.com/]Sports Jerseys China[/url]
[url=http://www.jersey2shop.com/NFL-Jerseys-c68/]NFL Jerseys China[/url]
[url=http://www.jersey2shop.com/NBA-Jerseys-c77/]NBA Jerseys China[/url]
NHL Jerseys China
[url=http://www.jersey2shop.com/MLB-Jerseys-c94/]MLB Jerseys China[/url]NFL jerseys For Sale online.All Our Jerseys Are Sewn On and Directly From Chinese Jerseys Factory
[/pre]
[pre]We Are Professional China jerseys Wholesaler
[url=http://www.cheapjersey2store.com/]Wholesale cheap jerseys[/url]Cheap mlb jerseys
[url= http://www.cheapjersey2store.com/]2012 mlb all atar jerseys[/url]
[url= http://www.cheapjersey2store.com/ [/url]Cheap China Wholesael[/url]
[url= http://www.cheapjersey2store.com/]Wholesale jerseys From China[/url]
[url=http://www.cheapjersey2store.com/]2012 nike nfl Jerseys[/url]Free Shipping,Cheap Price,7 Days Deliver
[/pre]
[/pre]
We are professional jerseys manufacturer from china,wholesal
sports [url= http://www.cheapjersey2store.com/]Jerseys From China[/url]
[url=http://www.cheapjersey2store.com/NFL-Jerseys-c68]NFL jerseys China[/url]
[url=http://www.cheapjersey2store.com/NHL-Jerseys-c96/]NHL Jerseys China[/url]
[url=http://www.cheapjersey2store.com/NBA-Jerseys-c77/]NBA Jerseys China[/url]
[url=http://www.cheapjersey2store.com/MLB-Jerseys-c94/]MLB Jerseys China[/url]
[url= http://www.cheapjersey2store.com/]China Jerseys[/url],Free Shipping
[/pre]
[/pre]
We are professional jerseys manufacturer from china,wholesal
sports [url= http://www.jerseycaptain.com/]cheap jerseys sale online [/url]
[url= http://www.jerseycaptain.com/]2012 nike nfl Jerseys[/url]
[url=http://www.jerseycaptain.com/NFL-Jerseys-c68]cheap NFL jerseys China[/url]
[url=http://www.jerseycaptain.com/NHL-Jerseys-c96/]NHL Jerseys C

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-26 4:16:32 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search