SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Senior Member
    Join Date
    Feb 2006
    Location
    Bangalore
    Posts
    593
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Problem in connecting to DB2

    I am trying to connect to a DB2 database. I am unable to get the right connection string. I do not have the OLEDB provider (Microsoft/IBM) installed. Please find the code below:
    {Errors encountered are explained along with the respective "ConnectionString".}

    <font class="small">Code:</font><hr /><pre>
    Function ConnectToDB2(myDataBase,myServerAddress,myUsername ,password)
    'On Error Resume Next
    Const adCmdText=1
    Const adStateOpen=1
    Const adUseClient=3
    Const adOpenForwardOnly=0
    Const adLockReadOnly=1

    Dim conDB2
    Dim cmdQuery
    Dim rsData
    Dim querytoRun
    Dim resultSet()
    Set conDB2=CreateObject("ADODB.Connection")
    '''***IBMOLEDBProvider
    'conDB2.ConnectionString="Provider=IBMDADB2;Databa se="&amp;myDataBase&amp;";Hostname="&amp;myServerA ddress&amp;";Protocol=TCPIP;Port=50000; Uid="&amp;myUsername&amp;";Pwd="&amp;password&amp; ";"

    <font color="red"> I got "SQL 1042C An unexpected system error occured. SQLSTATE=58004" </font>
    '''***Microsoft OLEDBprovider
    'conDB2.ConnectionString="Provider=DB2OLEDB;Databa se="&amp;myDataBase&amp;";Hostname="&amp;myServerA ddress&amp;";Protocol=TCPIP;Port=50000; Uid="&amp;myUsername&amp;";Pwd="&amp;password&amp; ";"

    <font color="red"> I got "Provider not installed properly"</font>
    '''***Standard
    conDB2.ConnectionString="Driver={IBM DB2 ODBC DRIVER};Database=DB2DEVL;Hostname=IPAddress;Port=P ort Number;Protocol=TCPIP;Uid=username;Pwd=password;"

    <font color="red">I got "SQL 1042C An unexpected system error occured. SQLSTATE=58004" </font>

    '''*****************************
    If Err.Number&lt;&gt;0 Then
    Msgbox Err.Description
    End If
    conDB2.Open
    If Err.Number&lt;&gt;0 Then
    Msgbox Err.Description
    End If
    Set cmdQuery=CreateObject("ADODB.Command")
    If Err.Number&lt;&gt;0 Then
    Msgbox Err.Description
    End If
    Set cmdQuery.ActiveConnection=conDB2
    cmdQuery.CommandText="SQL Query"
    cmdQuery.CommandType=adCmdText

    Set rsData=CreateObject("ADODB.Recordset")
    Set rsData.Source=cmdQuery
    rsData.CursorType=adOpenForwardOnly
    rsData.CursorLocation=adUseClient
    rsData.Open

    If rsData.State=adStateOpen Then
    Do While Not rsData.EOF

    Data1=rsData.Fields("Col1")
    Msgbox Data1
    Data2=rsData.Fields("Col2")
    Msgbox Data2
    Data3=rsData.Fields("Col3")
    Msgbox Data3
    '''Data4=rsData.Fields(""&amp;Data4&amp;"")
    '''Data5=rsData.Fields(""&amp;Data5&amp;"")
    rsData.MoveNext
    Loop

    rsData.Close
    Else
    Msgbox "Recordset not opened"
    End If

    Set rsData=Nothing
    Set cmdQuery=Nothing
    conDB2.Close
    Set conDB2=Nothing
    End Function

    myDataBase="DBName"
    myServerAddress="IPAddress"
    myUsername="Uid"
    password="Pwd"
    Call ConnectToDB2(myDataBase,myServerAddress,myUsername ,password)

    Let me know how this problem can be fixed.

    Thanks,

































    </pre><hr />
    Vengat Ramanan.R

  2. #2
    Senior Member
    Join Date
    Jan 2000
    Location
    USA, CA
    Posts
    1,998
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem in connecting to DB2

    Try:
    Provider=IBMDADB2.1

    Also:
    Instead of Hostname=IPAddress
    I'm using: Location=IPAddress

    Regards,
    Janna

  3. #3
    Senior Member
    Join Date
    Feb 2006
    Location
    Bangalore
    Posts
    593
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem in connecting to DB2

    Janna,

    Thanks for the help. I have found that the problem is not with the code or connection string. I saved the same code onto a .vbs and ran it. It is working fine. I do not know why I am not able to do it on QTP.

    Anyways the purpose is solved. I will keep posted what went wrong when I tried to implement from QTP. FYI I could not get it connected through the Query wizard too. I am getting the same error (1042c).
    Vengat Ramanan.R

  4. #4
    Junior Member
    Join Date
    Nov 2007
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem in connecting to DB2

    Hi Vengat/Janna,

    Did you get any solution for QTP issue for DB connect as I am getting the same error thru QTP?

    I treid to run the same code thru WScript engine by coverting it to vbscript engine and it works fine.Even the sam code works fine thru .vbs execution, But only when running thru QTP, I am getting the same error (1042c).

    Any help is greatly appreciated.

    Thanks,
    Hima

  5. #5
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Problem in connecting to DB2

    The problem is QTP configuration. Rename the QTPro.exe.local file to _QTPro.exe.local and restart QTP. It would be able to connect to the Database

  6. #6
    Junior Member
    Join Date
    Nov 2007
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem in connecting to DB2

    Thank You Tarun ...That helped.

    Thanks,
    Hima

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 03:53 AM.

Copyright BetaSoft Inc.