How to execute Store Procudure on IBM AS400-iSeries-System database ?


Recently i got the chance to work with IBM AS400-iSeries-System database i.e mainframe database. Process is very much similar to approach.

Firstly you have to install drive i.e IBM i Access for Windows

Then add the IBM.Data.DB2.iSeries dll in your application.

Now you can write the code like this.

Imports IBM.Data.DB2.iSeries

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

 Dim con As New iDB2Connection("Data source=;User Id=Test;Password=Test")
        Dim cmd As New iDB2Command()
        cmd = con.CreateCommand()
        cmd.CommandText = "trs.Test"
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.AddWithValue("@lib1", "TEL")
        cmd.Parameters.AddWithValue("@sUser", "admin")
        cmd.Parameters.AddWithValue("@ErrorMsgId", "")
        cmd.Parameters.AddWithValue("@ErrorMsg", "")
        cmd.Parameters("@ErrorMsgId").Direction = ParameterDirection.Output
        cmd.Parameters("@ErrorMsg").Direction = ParameterDirection.Output
        Dim da As New iDB2DataAdapter(cmd)
        Dim dt As New DataTable()
        Dim msg As String = cmd.Parameters("@ErrorMsgId").Value
        Dim msg1 As String = cmd.Parameters("@ErrorMsg").Value

    End Sub

End Class

It will fetch the data from database.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.