By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,686 Members | 1,510 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,686 IT Pros & Developers. It's quick & easy.

Connecting to a AS400 iSeries queue from .NET

P: 2
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
Oct 4 '06 #1
Share this Question
Share on Google+
3 Replies


P: 1
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



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
Oct 17 '07 #2

P: 5
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.
Dec 4 '07 #3

P: 1
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.

Expand|Select|Wrap|Line Numbers
  1. Public Function CallAS400Queue(ByVal pOrderNumber As String) As Boolean
  2.  
  3.         'Create the ODBC objects
  4.         Dim OdbcCon As System.Data.Odbc.OdbcConnection
  5.         Dim OdbcCmd As System.Data.Odbc.OdbcCommand
  6.         Dim command As String
  7.         Try
  8.             command = "call qsys.qsnddtaq ('EMAIL     ','QGPL      ',X'00030F','PF<OrderID>.XML')"
  9.             command = command.Replace("<OrderID>", pOrderNumber)
  10.  
  11.             'Instantiate new instances
  12.             OdbcCon = New System.Data.Odbc.OdbcConnection
  13.  
  14.             'Open a connection to an iSeries data source       
  15.             OdbcCon.ConnectionString = My.Settings.AS400_DBConnection
  16.             'Open the connection
  17.             OdbcCon.Open()
  18.  
  19.             OdbcCmd = New System.Data.Odbc.OdbcCommand(command, OdbcCon)
  20.  
  21.             Try
  22.                 OdbcCmd.ExecuteNonQuery()
  23.             Catch oException As Exception
  24.                 Throw oException
  25.             Finally
  26.                 'close the connection
  27.                 OdbcCon.Close()
  28.                 OdbcCon.Dispose()
  29.             End Try
  30.         Catch oException As Exception
  31.             Throw oException
  32.         End Try
  33.         Return True
  34.     End Function
  35.  
Dec 11 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.