Sunday, October 7, 2012

Rexx and DB2

/*-----------------------REXX-----------------------------------------*/


ADDRESS TSO "SUBCOM DSNREXX" /* DSNREXX ENVIRONMENT AVILABLE?*/

IF RC <> 0 THEN

S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')



SSID='ssid'

SQ1='SELECT Query'



ADDRESS DSNREXX

"CONNECT" SSID

"EXECSQL DECLARE C1 CURSOR FOR S1"

DROP OUTSQLDA1

"EXECSQL PREPARE S1 INTO :OUTSQLDA1 FROM :SQ1"

"EXECSQL OPEN C1"

IF SQLCODE ¬= 0 THEN DO

SAY 'ERROR OPENING CURSOR'

EXIT 0

END

"EXECSQL FETCH C1 USING DESCRIPTOR :OUTSQLDA1"

DO UNTIL SQLCODE ¬= 0

IF SQLCODE = 0 THEN DO

select_field1 = STRIP(OUTSQLDA1.1.SQLDATA)

select_field2 = STRIP(OUTSQLDA1.2.SQLDATA)

END

"EXECSQL FETCH C1 USING DESCRIPTOR :OUTSQLDA1"

END

"EXECSQL CLOSE C1"

ADDRESS "TSO"

/*-------------------------- END OF PROGRAM --------------------------*/



REXX to update/insert/delete data in a DB2 table



/*-----------------------REXX-----------------------------------------*/

ADDRESS TSO "SUBCOM DSNREXX" /* DSNREXX ENVIRONMENT AVILABLE?*/

IF RC <> 0 THEN

S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')

SSID='ssid'

SQ1='INSERT/UPDATE/DELETE Query'

ADDRESS DSNREXX

"CONNECT" SSID

"EXECSQL PREPARE S1 FROM :SQ1"

"EXECSQL EXECUTE S1"

"EXECSQL COMMIT"

SAY ' --> SQLCODE='SQLCODE

ADDRESS "TSO"

RETURN

/*-------------------------- END OF PROGRAM --------------------------*/





The above Rexx can also be executed from within a job(JCL) as shown bellow:



//************************************************

//STEP010 EXEC PGM=IKJEFT01,DYNAMNBR=75

//SYSPROC DD DISP=SHR,DSN=Your-REXX-Library

//SYSTSPRT DD SYSOUT=*

//SYSPRINT DD SYSOUT=*

//SYSTSIN DD *

YOURREXX-NAME

/*





Common Errors:

1)

Job abended with MAXCC=12.

spool information in SYSTSPRT



+++ S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')

Error running YOURREXX-NAME, line 62: Routine not found



You may have to add a SDSNLOAD library(that contains a member RXSUBCOM) to joblib in your JCL.

e.g.

//JOBLIB DD DSN=ssidPRD.ssid.SDSNLOAD,DISP=SHR



JCL for executing rexx in batch

//***** JOB STEP for executing REXX program that uses two arguments ******


//STEP01 EXEC PGM=IKJEFT01

//SYSEXEC DD DISP=SHR,DSN=UID.NARINDER.REXX

//SYSPRINT DD SYSOUT=*

//SYSTSPRT DD SYSOUT=*

//SYSTSIN DD *

TESTARG NARINDER SINGH

/*





/* REXX for above JCL job that uses two arguments */

ARG arg1 arg2

QUEUE arg1 arg2

"ALLOC FI(XXOUT) DA(REXX.OUTPUT) MOD REUSE"

IF RC \= 0 THEN

DO

SAY '*** ERROR - OUTPUT ALLOCATION FAILED: ABENDING'

EXIT 0

END

"EXECIO" Queued() "DISKW XXOUT (FINIS"

"FREE F(XXOUT)"

EXIT

Monday, July 26, 2010

How to embed flash swf in php??


<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100%" height="161">
      <param name="movie" value="images/header.swf" />
      <param name="quality" value="high" />
      <embed src="images/header.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="161"></embed>
    </object>



Code for embedding flash movie files(swf) in php.

   1:  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100%" height="161">


   2:        <param name="movie" value="images/header.swf" />


   3:        <param name="quality" value="high" />


   4:        <embed src="images/header.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="161"></embed>


   5:      </object>


Sunday, July 25, 2010

Database handling in php.

 

first open phpmyadmin and then create a new database named “test”( for the specific purpose of this example).

now create a table inside it named “counter” with a field “count” in it. ( integer,NULL,unsigned)

Now, create a file named server_auth.php in (root)/config folder. this folder you must remove all accessing permissions.

in server_auth.php

<?php 
$db_host = "localhost";
$db_user = "root";
$db_password = "";
$db_name = "test";
?>



 



create another file in your webroot named “ counter.php



<?php 
require($_SERVER["DOCUMENT_ROOT"]."/config/server_auth.php");
$connection = @mysql_connect($db_host,$db_user,$db_password) or die("error connecting the database!");
mysql_select_db($db_name, $connection);
$query = "SELECT * FROM counter";
$result = mysql_query($query, $connection) or die(mysql_error());
$views = mysql_result($result, 0, "count");
$views++;
$query = "UPDATE counter SET count = $views";
mysql_query($query, $connection) or die(mysql_error());
echo "This page has been viewed ".$views. " times.";
?>



ALL DONE! just open that counter.php in your browser and it will display a hit count!

Friday, June 4, 2010

Connecting to Database by writing code in VB.NET (Widout wizard)

Step 1. Add reference to system.data in your code

Click project->Add Reference

Select .Net tab

Select System.Data

Now click Ok.

Step 2. before Public Class Form1, write

Imports System.Data

Step 3. In Form load event

Dim Con As new OleDb.OleDbConnection

Step 4. Now write next

Con.Connectionstring=”PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydatabase.mdb”

End Sub

Step 5. Open the connection to database with

Con.Open()

and display a msgbox to test the successful connection

msgbox(“the connection is opened”)

Step 6. Create new dataset and data adapter.

Dim ds As New DataSet

Dim da As OleDb.OleDbDataAdapter

Step 7. Pass new sql query to the data adapter

Dim sql As String

sql=”SELECT * FROM mydatabasetable1”

da=New OleDb.OleDbDataAdapter(sql,con)

This is how your Code should look like

oledbCodeNew

Finally Fill the dataset with data.

da.Fill(ds,”mybase”)

This connects the database to dataset and fills it. Just that the data can’t be seen till now by anyone since it is not binded to any user viewable control.

txtFirstName.Text = ds.Tables("mydatabasetable").Rows(0).Item(1)

for further reading…http://www.homeandlearn.co.uk/NET/nets12p6.html

Final sample code::::::

 


Private Sub Frmmain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim conn As New OleDb.OleDbConnection
    conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=pdjm.accdb;Persist Security Info=True;Jet OLEDB:Database Password=password123"
    Dim ds As New DataSet
    Dim da As New OleDb.OleDbDataAdapter
    Dim sql As String
    sql = "SELECT * FROM programmgmt"
    da = New OleDb.OleDbDataAdapter(sql, conn)
    da.Fill(ds, "mybase")
    DataGridView1.DataSource = ds.Tables("MyBase")