How to catalog db2 database with visual basic (vb or vba)?

Posted on 2009-12-22
Last Modified: 2013-12-25
Appr. 50 users access an MS Access application, from where the connection to DB2 database via ODBC has to be used. I know, how to build an ODBC connection to a registered (with "catalog db") DB2 database. But most of users have this DB2 database not catalogged yet. How to catalog a DB2 database from VBA-code? The server (IP), database name and port are known.
Question by:inversojvo
    LVL 28

    Expert Comment


    Author Comment

    2 peakpeak: these are descriptions of connecting to DB2 database, that is already catalogged on the client PC. I need the answer, how to catalog the DB2 database, that wasn't catalogged yet. I can do it from CLI manually, but I don't wont to do it manually on each of 50 clients PC and to go to client each time, when new PC is installed.

    I know, how to build ODBC connection to exisiting DNS source, I know how to create DNS source from vba, but how to catalog the DB2 database?? I suppose, I could do it with registry entry, but may be, the easier way does exist, with some predefined VB libraries or so...
    LVL 37

    Expert Comment


    Author Comment

    you can try to use some cli api in order to do it, but it will probably be rather complex
    if you can just invoke the db2cfimp.exe file, you can prepare a configuration export file with the appropriate cataloged entry and then import it from your code

    (copied from, the question there will be closed)

    Author Comment

    2 momi_sabag: I don't understand quite well - do you mean, that I have to prepare the configuration file with the "catalog" command and then just call db2cfimp.exe with the configuration file name as parameter?

    F.e.x. if I can catalog the node and then the db, that I need, with the following commands from CLI:

    db2cmd db2 catalog tcpip node AXDAB02T remote server 50009
    db2cmd db2 catalog db RISITEST at node AXDAB02T

    So, you mean, that I make a file "catalog.cfg" with 2 this lines and call the from VBA smth. like shell(<pathToDb2cfimp>/db2cfimp.exe <pathToCfg>/catalog.cfg), the cataloging will be made?
    LVL 37

    Accepted Solution

    you can either run those commands,
    or run db2cfexp on a compuer with that database catalog, db2cfexp will produce a file you can later use as input for db2cfimp

    Author Closing Comment

    Sorry for late answer and thanx for the help!!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now