1. You have to install the Client Access for iSeries on the server executing the code.
2. Here is a example piece of code.
The connection string in the application settings My.Settings.AS400_DBConnection being in the format off
Provider=MSDASQL;DSN=ODBCNAME;UID=username;PWD=xxx xx;
where ODBCNAME is a ODBC connection you've set up using the iSeries driver.
You can of course vary what the last parameter contains ('PF<OrderID>.XML') by altering the command string and/or the replace function as well as of course the incoming parameters to the function.
-
Public Function CallAS400Queue(ByVal pOrderNumber As String) As Boolean
-
-
'Create the ODBC objects
-
Dim OdbcCon As System.Data.Odbc.OdbcConnection
-
Dim OdbcCmd As System.Data.Odbc.OdbcCommand
-
Dim command As String
-
Try
-
command = "call qsys.qsnddtaq ('EMAIL ','QGPL ',X'00030F','PF<OrderID>.XML')"
-
command = command.Replace("<OrderID>", pOrderNumber)
-
-
'Instantiate new instances
-
OdbcCon = New System.Data.Odbc.OdbcConnection
-
-
'Open a connection to an iSeries data source
-
OdbcCon.ConnectionString = My.Settings.AS400_DBConnection
-
'Open the connection
-
OdbcCon.Open()
-
-
OdbcCmd = New System.Data.Odbc.OdbcCommand(command, OdbcCon)
-
-
Try
-
OdbcCmd.ExecuteNonQuery()
-
Catch oException As Exception
-
Throw oException
-
Finally
-
'close the connection
-
OdbcCon.Close()
-
OdbcCon.Dispose()
-
End Try
-
Catch oException As Exception
-
Throw oException
-
End Try
-
Return True
-
End Function
-