J
j090757
Returning parm data to vb.net from AS400 stored procedure
This example loads a textbox which is used by javascript for error
handling.
First create the stored procedure on the AS400:
CREATE PROCEDURE KBMCUSTOM/RUSECW55(INOUT :li CHAR ( 10), INOUT w
CHAR ( 10), INOUT :dp CHAR ( 10), INOUT :er CHAR ( 10), INOUT :np
CHAR ( 10)) RESULT SETS 1 LANGUAGE RPGLE NOT DETERMINISTIC NO SQL
EXTERNAL NAME KBMCUSTOM/RUSECW55 PARAMETER STYLE GENERAL
Now reference the stored procedure in VB.
Dim ConnString As String = "DSN=AS400;UID=lvernon;PWD=testweb"
Dim myConnection As New OdbcConnection(ConnString)
Dim myStoredProc As String = "CALL
KBMCUSTOM.RUSECW55(?,?,?,?,?)"
Dim myCommand As New OdbcCommand(myStoredProc, myConnection)
myCommand.CommandType() = CommandType.StoredProcedure
Dim myParameter1 As New OdbcParameter(Me.txtLogin.Text,
Odbc.OdbcType.Char, 10)
Dim myParameter2 As New OdbcParameter(Me.txtPassword.Text,
Odbc.OdbcType.Char, 10)
Dim myParameter3 As New OdbcParameter(Me.txtDept.Text,
Odbc.OdbcType.Char, 10)
Dim myParameter4 As New OdbcParameter(Me.txtSvrerr.Text,
Odbc.OdbcType.Char, 10)
Dim myParameter5 As New OdbcParameter(Me.txtNPassword.Text,
Odbc.OdbcType.Char, 10)
myParameter1.Direction = ParameterDirection.InputOutput
myCommand.Parameters.Add(myParameter1).Value =
Me.txtLogin.Text
myParameter2.Direction = ParameterDirection.InputOutput
myCommand.Parameters.Add(myParameter2).Value =
Me.txtPassword.Text
myParameter3.Direction = ParameterDirection.InputOutput
myCommand.Parameters.Add(myParameter3).Value = Me.txtDept.Text
myParameter4.Direction = ParameterDirection.InputOutput
myCommand.Parameters.Add(myParameter4).Value =
Me.txtSvrerr.Text
myParameter5.Direction = ParameterDirection.InputOutput
myCommand.Parameters.Add(myParameter5).Value =
Me.txtNPassword.Text
myConnection.Open()
myCommand.ExecuteNonQuery()
Me.txtSvrerr.Text = myParameter4.Value
myConnection.Close()
This example loads a textbox which is used by javascript for error
handling.
First create the stored procedure on the AS400:
CREATE PROCEDURE KBMCUSTOM/RUSECW55(INOUT :li CHAR ( 10), INOUT w
CHAR ( 10), INOUT :dp CHAR ( 10), INOUT :er CHAR ( 10), INOUT :np
CHAR ( 10)) RESULT SETS 1 LANGUAGE RPGLE NOT DETERMINISTIC NO SQL
EXTERNAL NAME KBMCUSTOM/RUSECW55 PARAMETER STYLE GENERAL
Now reference the stored procedure in VB.
Dim ConnString As String = "DSN=AS400;UID=lvernon;PWD=testweb"
Dim myConnection As New OdbcConnection(ConnString)
Dim myStoredProc As String = "CALL
KBMCUSTOM.RUSECW55(?,?,?,?,?)"
Dim myCommand As New OdbcCommand(myStoredProc, myConnection)
myCommand.CommandType() = CommandType.StoredProcedure
Dim myParameter1 As New OdbcParameter(Me.txtLogin.Text,
Odbc.OdbcType.Char, 10)
Dim myParameter2 As New OdbcParameter(Me.txtPassword.Text,
Odbc.OdbcType.Char, 10)
Dim myParameter3 As New OdbcParameter(Me.txtDept.Text,
Odbc.OdbcType.Char, 10)
Dim myParameter4 As New OdbcParameter(Me.txtSvrerr.Text,
Odbc.OdbcType.Char, 10)
Dim myParameter5 As New OdbcParameter(Me.txtNPassword.Text,
Odbc.OdbcType.Char, 10)
myParameter1.Direction = ParameterDirection.InputOutput
myCommand.Parameters.Add(myParameter1).Value =
Me.txtLogin.Text
myParameter2.Direction = ParameterDirection.InputOutput
myCommand.Parameters.Add(myParameter2).Value =
Me.txtPassword.Text
myParameter3.Direction = ParameterDirection.InputOutput
myCommand.Parameters.Add(myParameter3).Value = Me.txtDept.Text
myParameter4.Direction = ParameterDirection.InputOutput
myCommand.Parameters.Add(myParameter4).Value =
Me.txtSvrerr.Text
myParameter5.Direction = ParameterDirection.InputOutput
myCommand.Parameters.Add(myParameter5).Value =
Me.txtNPassword.Text
myConnection.Open()
myCommand.ExecuteNonQuery()
Me.txtSvrerr.Text = myParameter4.Value
myConnection.Close()