Connecting to DB2 using VB 6.0


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Connecting to DB2 using VB 6.0

Hybrid View

  1. #1
    Randy Guest

    Connecting to DB2 using VB 6.0


    Checking to see if anyone may know how to connect a VB app to DB2? I am familiar
    with ADO connection strings as used to connect to SQL, but don't believe
    the same method olds true for connecting to DB2. Can anyone educate me a
    little?

    Thanks
    Randy

  2. #2
    Craig Brown Guest

    Re: Connecting to DB2 using VB 6.0


    Randy,

    As far as I know you need to install DB2 client software on your PC and then
    add the database(s) via the ODBC control panel process or through the DB2
    client software. (This is one of those things, that, as an application developer
    you know you need, you get it installed and then promptly forget the details....
    And it's been awhile for me....)

    Send me an email if you need more specifics and I'll get the low-down from
    our DBAs.

    Craig Brown


    "Randy" <randallbaxter@earthlink.net> wrote:
    >
    >Checking to see if anyone may know how to connect a VB app to DB2? I am

    familiar
    >with ADO connection strings as used to connect to SQL, but don't believe
    >the same method olds true for connecting to DB2. Can anyone educate me a
    >little?
    >
    >Thanks
    >Randy



  3. #3
    Tom Egan Guest

    Re: Connecting to DB2 using VB 6.0


    Hi Randy,
    I am using Client Access every day to talk to DB2/400.
    I use Microsoft Access, Microsoft Excel, and several home grown VB
    applications to communicate.
    I "talk" via RDO, ADO, and OLEDB.

    I'll be glad to help all I can. need some details !!!..

    Tom Egan
    tegan@bellsouth.net







    "Craig Brown" <brownc3@ing-afs.com> wrote:
    >
    >Randy,
    >
    >As far as I know you need to install DB2 client software on your PC and

    then
    >add the database(s) via the ODBC control panel process or through the DB2
    >client software. (This is one of those things, that, as an application developer
    >you know you need, you get it installed and then promptly forget the details....
    >And it's been awhile for me....)
    >
    >Send me an email if you need more specifics and I'll get the low-down from
    >our DBAs.
    >
    >Craig Brown
    >
    >
    >"Randy" <randallbaxter@earthlink.net> wrote:
    >>
    >>Checking to see if anyone may know how to connect a VB app to DB2? I am

    >familiar
    >>with ADO connection strings as used to connect to SQL, but don't believe
    >>the same method olds true for connecting to DB2. Can anyone educate me

    a
    >>little?
    >>
    >>Thanks
    >>Randy

    >



  4. #4
    John Guest

    Re: Connecting to DB2 using VB 6.0


    Hi,
    I installed Client Access Express (version 4, release 4, modification 0).
    Make sure you install the ADO part. I use this functions to retrieve data.
    Maybe it helps. Good luck! (tip: look for a file called "cwbundbs.exe", it's
    a great tool to execute queries.
    ~John

    Public Function Get400Connection(strSystemName As String, strUserId As String,
    _
    strPassword As String) As ADODB.Connection
    Set Get400Connection = New ADODB.Connection
    Get400Connection.Open "Provider=IBMDA400;Data Source=" & strSystemName
    & ";", _
    strUserId, strPassword
    End Function


    Public Function Get400Records(strSQL As String, p_cn400 As ADODB.Connection)
    As ADODB.Recordset
    'example: Set rs = Get400Records("SELECT * FROM MIDFILES.obcop100", cn)
    Dim AS400Command As ADODB.Command
    Set AS400Command = New ADODB.Command
    Set AS400Command.ActiveConnection = p_cn400
    AS400Command.Properties("Updatability") = 0 'Don't change order (or
    property!)
    AS400Command.CommandText = strSQL
    AS400Command.CommandType = adCmdText
    AS400Command.Prepared = False
    'AS400Command.Parameters.Refresh
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Set Get400Records = AS400Command.Execute
    End Function


    "Tom Egan" <tegan@bellsouth.net> wrote:
    >
    >Hi Randy,
    > I am using Client Access every day to talk to DB2/400.
    > I use Microsoft Access, Microsoft Excel, and several home grown VB
    >applications to communicate.
    >I "talk" via RDO, ADO, and OLEDB.
    >
    >I'll be glad to help all I can. need some details !!!..
    >
    >Tom Egan
    >tegan@bellsouth.net
    >
    >
    >
    >
    >
    >
    >
    >"Craig Brown" <brownc3@ing-afs.com> wrote:
    >>
    >>Randy,
    >>
    >>As far as I know you need to install DB2 client software on your PC and

    >then
    >>add the database(s) via the ODBC control panel process or through the DB2
    >>client software. (This is one of those things, that, as an application

    developer
    >>you know you need, you get it installed and then promptly forget the details....
    >>And it's been awhile for me....)
    >>
    >>Send me an email if you need more specifics and I'll get the low-down from
    >>our DBAs.
    >>
    >>Craig Brown
    >>
    >>
    >>"Randy" <randallbaxter@earthlink.net> wrote:
    >>>
    >>>Checking to see if anyone may know how to connect a VB app to DB2? I am

    >>familiar
    >>>with ADO connection strings as used to connect to SQL, but don't believe
    >>>the same method olds true for connecting to DB2. Can anyone educate me

    >a
    >>>little?
    >>>
    >>>Thanks
    >>>Randy

    >>

    >



  5. #5
    Mark Guest

    Re: Connecting to DB2 using VB 6.0


    Randy,
    If you are using the Windows Enterprise version of DB2 you need to install
    the client access software that comes with it. If you are using Personal
    DB2, just install the Database. You should also get the most current Fixpack
    from the DB2 site. If you don't you won't be able to use the OLE provider
    for DB2 (need to for MTS). I would advise you to use ADO (need to use most
    current version) because it will make the transition to .NET easier. Also
    if you are planning to implement this in an enterprise environment, I would
    suggest not having the client directly access the database. This will save
    you alot of installation head aches and license fees.

    If the DB2 database is another platform the you will need to use something
    like DB2 connect.

    Mark


    "Randy" <randallbaxter@earthlink.net> wrote:
    >
    >Checking to see if anyone may know how to connect a VB app to DB2? I am

    familiar
    >with ADO connection strings as used to connect to SQL, but don't believe
    >the same method olds true for connecting to DB2. Can anyone educate me a
    >little?
    >
    >Thanks
    >Randy



  6. #6
    Terry Guest

    Re: Connecting to DB2 using VB 6.0


    Connecting VB6 to DB2 ver 7.0 /7.1

    The first step is to install the PC side client software so you have the
    ODBC driver on your machine.
    To do this, browse the CD and in the root directory you will find a setup.exe
    file to run. Click on the install button. Note that on a Windows 95/98 machine
    you will be presented with the option to install the DB2 Administration Client.
    The DB2 Personal Edition is already selected so now all you need to do is
    select the DB2 Administration Client install also. Now you are ready to click
    on the next button to continue the installation.

    Next...
    Choose "Custom" for the installation choice. Click next to continue and sit
    back and wait for six weeks while the install creeps along!
    Once the install has been completed and you have re-booted your system a
    dialog box may pop up asking you if you want to install a sample database.
    Go ahead and install it if you want to cuz it is nice to have for testing
    purposes! What we want to do in the next step is go to your program group
    under the startup menu and select the DB2 folder icon and then the "Client
    Configuration Assistant".

    Next...
    When the dialog box pops up click on the "Add" button and then choose the
    "Manual" installation. Now choose the TCP/IP option and then click on the
    "Next" button. Under the text input box entitled "Host Name" put in the IP
    address of the RS6000 or whatever machine you are trying to connect to...
    (000.000.000.000) Under the "Port Address" option put in 50000 and ignore
    the option for "Service Name". Hit the "Next" button to continue. Enter the
    "Database Name" of your database and you will notice that the "Database Alias"
    will be entered automatically for you. Ignore the comment field and hit the
    "Next" button.

    Next...
    Make sure that the "Register This Database For ODBC" is checked and that
    the bullet next to "As a System Data Source" is selected. Don't worry about
    the option to "Optimize For Application". Now click on the finish button.
    That's right, we don't want to go any further than this!

    Next...
    Now we want to click on the "Test Connection" button. Use the database's
    "standard" sign-on and after you have verified the connection click on the
    close button.

    Next...
    Now we need to register our DB2 Database. Do this by first clicking on the
    new Database icon and then selecting properties. Select "Register This Database
    For ODBC". Now click on the "Settings" button and when prompted to connect
    choose "Yes". Sign-on with the "standard" sign-on again. When presented with
    the dialog box, enter the name of "your database" followed by a space and
    then "VB6" exactly as shown hear except the quotes! Don't worry about filling
    in anything under the Description field and DON'T put in anything under the
    User Name Or Password fields! You can code this into your application later!
    If you put it in here any connection made in the future will have access
    without security!! Now you will need to click on the O.K. button for each
    of three screens in succession.

    Next...
    Now we need to click on the database icon again and this time choose the
    "Bind " option. Select "Bind DB2 Utilities" and then click on the continue
    button. Log in as "standard user" again and make sure that all of the items
    presented have been selected, if not, choose the "Select All" command and
    then hit the "O.K." button. Now you must WAIT for the "Close" option to become
    available for you to click on. Before clicking on the "Close" button make
    sure you didn't get any errors in the process that was just run. Scroll through
    the list and verify that you have "0" errors all of the way through the above
    process. When you have verified the above, click on "Close" and when you
    are brought back to the main screen click on "Close" again. Whew!! That was
    a long process!!
    One word of caution. If you install on a Windows NT box or Windows 2000 box
    you may run into a problem where certain "Services" don't get started automatically
    as they should. This happened to me on one machine. I was able to overcome
    this by going into the Services applet and then entering the Specifics for
    starting the services by setting the "Run As" option with the user "standard
    user log in and password". This didn't take the first time around but with
    persistence I was able to get it to take it and then start up the services.
    Below I will list the two services that needed attention…

    The "DB2 Security Server" and the "DB2 JDBC Applet Server". The error message
    I was getting by the way was as follows…

    "The DB2 Security Server Failed To Start Do To The Following Error…"
    "Access Denied."

    "The DB2 JDBC Applet Server Failed To Start Do To The Following Error…"
    "Access Denied."


    These two error messages popped up after the installation of the DB2 Universal
    Database CD was installed and the system was re-booted. I hope you had as
    much fun as I did!!

    Now you are ready to connect with VB6!!
    Use an ADO control for starters and later on you can code your own connections
    as needed. After dropping an ADO control on the form right click it and select
    properties. Choose the Use Connection string and then click on "Build". Now
    choose use data source name and use the pull down to select your new ODBC
    connection that we created above. Put in a user name and password and click
    on allow saving of password. Click on the advanced tab and choose read-only...
    This will let you play all you want in this project without the fear of damaging
    any data!! Enter a select statement to grab some data, keep it short and
    simple in the beginning...
    You can do this in the properties box of the ADOC control or while building
    a connection... I do one while building a connection and then play with the
    string a bit in the properties later...

    To keep it simple in the beginning, just drop a "Datagrid" on the form and
    bind it to the ADOC control...

    The rest is up to you!!! Play and have fun!!!

    Terry



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center