Welcome to MSDN Blogs Sign in | Join | Help

How to get DB2 ServerClass and ServerVersion for your DB2 instance.

here is code snippet using DataAccessLibrary that ships with :

1. Microsoft Host Integration Server AND

2. Microsoft Biztalk Adapters for Host Systems AND

3. Microsoft's DB2OLEDB (SQL server feature pack for DB2 ) .

if you have any of these , following code will help getting  your DB2 server's version and class ( MVS or AS400 or NT etc.)

 

 

//referencesspan style="mso-spacerun:yes">  required to be added in your project - Microsoft.HostIntegration.DataAccessLibrary.dll

using System;

using Microsoft.HostIntegration.DataAccessLibrary;

using System.Diagnostics;

 

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            string serverClass = String.Empty;

            string serverVersion = String.Empty;

 

            try

            {

                DataAccessControl control = new DataAccessControl();

               //DB2.UDL is the connection to DB2 server( Created with DAT- Data Access Tool)

                IConnectionString cnstr = DB2OleDbConnectionString.ReadUDL(@"DB2.UDL");

                DataAccessControl.TestConnection(cnstr, out serverClass, out serverVersion);

 

                Console.WriteLine("serverClass" + serverClass);

                Console.WriteLine("serverVersion" + serverVersion);

           

            }

            catch(Microsoft.HostIntegration.DataAccessLibrary.ConnectionException e)

            {

                Console.WriteLine("failed to connect " + e.ToString());

            }

 

        }

    }

}

 

Published Wednesday, July 08, 2009 6:08 PM by asmitaw

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker