Connecting to a AS400 iSeries queue from .NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mortsdeh
    New Member
    • Oct 2006
    • 2

    Connecting to a AS400 iSeries queue from .NET

    Hi,

    I have been assigned to connect to a AS400 queue using the iSeries API, probably version 5 release 3. I use Visual Basic.NET in Visual Studio.NET 2003.

    I would be grateful for all input regarding this problem, since I don't really have any ideas on how to start.

    Questions:
    1. I am not gonna connect to a database, only a queue e.g. the queue QSNDDTAQ. Are any installations required on the client as well as the server to be able to connect to the queue.

    2. Can anyone provide code examples, preferrably in VB.NET but any .NET language will do?

    3. Anyone know of an Internet resource I can read?

    Best
    /M
  • tomkrise
    New Member
    • Oct 2007
    • 1

    #2
    Hi Mortsdeh

    Did you find any solution regarding the connection to AS400 queue ?
    Please let me know - I have been assigned a similar project using VB.NET.

    Many Thanks
    Tom



    Originally posted by Mortsdeh
    Hi,

    I have been assigned to connect to a AS400 queue using the iSeries API, probably version 5 release 3. I use Visual Basic.NET in Visual Studio.NET 2003.

    I would be grateful for all input regarding this problem, since I don't really have any ideas on how to start.

    Questions:
    1. I am not gonna connect to a database, only a queue e.g. the queue QSNDDTAQ. Are any installations required on the client as well as the server to be able to connect to the queue.

    2. Can anyone provide code examples, preferrably in VB.NET but any .NET language will do?

    3. Anyone know of an Internet resource I can read?

    Best
    /M

    Comment

    • renestigter
      New Member
      • Dec 2007
      • 5

      #3
      Hi,

      the queue you are describing QSNDDTAQ is not a queue but the actual API on the AS400 which is used within OS400 to put data in a queue. A queue can be any name of 10 characters and exists in the library system of the AS400.
      The queue can be fifo, lifo or keyed.
      I do not have any experience with .net and how to access queues on the AS400 but I have done it in Java. I assume there are certain API's available to connect to these queues. You just need to know the exact name, libary where it exists and if it is keyed or not.

      Comment

      • Colin D
        New Member
        • Dec 2007
        • 1

        #4
        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.AS4 00_DBConnection being in the format off
        Provider=MSDASQ L;DSN=ODBCNAME; UID=username;PW D=xxxxx;
        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>.X ML') by altering the command string and/or the replace function as well as of course the incoming parameters to the function.

        Code:
        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

        Comment

        Working...