SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    May 2004
    Location
    Mumbai
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    unable to connect to database

    I am face problem while execting the following code can somebudy help me out ?


    Const adOpenStatic = 3
    Const adLockOptimistic = 3
    Const adUseClient = 3

    Set objConnection = CreateObject("ADODB.Connection")
    Set objRecordset = CreateObject("ADODB.Recordset")

    objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=<UID>;PWD=<PWD>"

    objRecordset.CursorLocation = adUseClient
    objRecordset.CursorType = adopenstatic
    objRecordset.LockType = adlockoptimistic

    ObjRecordset.Source = "select field1,field2 from testTable"
    ObjRecordset.ActiveConnection = ObjConnection
    ObjRecordset.Open 'This will execute your Query

    If ObjRecordset.recordcount>0 Then
    Field1 = ObjRecordset("Field1").Value
    Field2 = ObjRecordset("Field2").Value
    End If

  2. #2
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: unable to connect to database

    What is the error description and which line is throwing it?

  3. #3
    Senior Member
    Join Date
    Jun 2005
    Location
    USA
    Posts
    235
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: unable to connect to database

    Surely (I hope) you are not executing the exact code you posted, as it is an example that lacks values specific to your DB (UID, PWD, table and column names).

    In addition to TReddy's question, post your actual code maybe, too.
    If ya got beef then fool eat a pork chop.

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

    Re: unable to connect to database

    Hey, i see the variable objConnection is being used as ObjConnection, and since qtp script is case sensitive, may be ur code is failing because of that,
    change the variable and try again, it should work.

    Suma.

  5. #5
    Senior Member
    Join Date
    Sep 2004
    Location
    Phoenix, AZ
    Posts
    198
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: unable to connect to database

    [ QUOTE ]
    objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=<UID>;PWD=<PWD>"

    [/ QUOTE ]

    where is the server name here? You need to give the server name too. like this

    "DRIVER={Microsoft ODBC for Oracle};SERVER=QA.google.com;UID=xyz;PWD=abc"


    Thanks!
    VasuK
    Thanks!
    VasuK

  6. #6
    Senior Member
    Join Date
    Sep 2004
    Location
    Phoenix, AZ
    Posts
    198
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: unable to connect to database

    [ QUOTE ]
    Hey, i see the variable objConnection is being used as ObjConnection, and since qtp script is case sensitive, may be ur code is failing because of that,
    change the variable and try again, it should work.

    Suma.

    [/ QUOTE ]

    QTP script editor is not case sensitive. we can use any variable name we want(except key words,reg words). Instead of "objConnection" we can declare "oconn" or "Oconn" or any thing.
    Thanks!
    VasuK

  7. #7
    Member
    Join Date
    May 2004
    Location
    Mumbai
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: unable to connect to database

    It was throughing an error on line
    "DRIVER={Microsoft ODBC for Oracle};UID=xyz;PWD=abc"

    but now its working fine, by following code.

    ObjConnection.Provider= "Microsoft.Jet OLEDB.4.0"
    ObjConnection.open "Test1","Admin","Admin"
    or
    ObjConnection.open "C:\Temp\db1.mdb"

 

 

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 9.38%
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 12:52 AM.

Copyright BetaSoft Inc.