SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Nov 2005
    Posts
    49
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Can I grab the TestPartner database name?

    Hopefully an easy one. I would like to grab the name of the TP database I'm logged into (for external logging purposes).

    I could hard-code it in my error-handler but when cloning/restoring to a new database I'm sure I'd forget to make the necessary change. (We clone/restore to a new database for each release of our product, which is every 3 months)

    I apologize if I missed it in a previous post; I searched with no luck.

    TP 6.1 Build 255

    Thanks,
    Andy

  2. #2
    Junior Member
    Join Date
    Sep 2007
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Can I grab the TestPartner database name?

    This isn't the write language, but the reg keys included should point you to where you can find the databases...

    <font class="small">Code:</font><hr /><pre>

    Public Sub PopulateList()

    'upon load, i want to populate the dropdown box with the DSN connections, taken from the registry
    Dim rootKey As RegistryKey
    Dim currentDB As String
    Dim subk As String
    Dim temp As String

    'open registry and find currently selected DB in TestPartner
    rootKey = Registry.CurrentUser
    rootKey = rootKey.OpenSubKey("SOFTWARE", True)
    rootKey = rootKey.OpenSubKey("Compuware", True)
    rootKey = rootKey.OpenSubKey("TestPartner", True)
    rootKey = rootKey.OpenSubKey("Login", True)
    currentDB = rootKey.GetValue("Database").ToString()

    'now switch to ODBC location
    rootKey = Registry.LocalMachine
    rootKey = rootKey.OpenSubKey("SOFTWARE", True)
    rootKey = rootKey.OpenSubKey("ODBC", True)
    rootKey = rootKey.OpenSubKey("ODBC.INI", True)

    'loop through the ODBC folder and add each item to collection (combobox)
    For Each subk In rootKey.GetSubKeyNames()
    'some of the DSNs I know are not going to be TestParnter usable databases, so dont even list them
    If subk = "ASAKLHELV" Or subk = "ASAKLTARIF" Or subk = "HELVBUTA" Or subk = "TP_EDIT" Or subk = "TP_EXEC" Or subk = "LocalServer" Or subk = "ODBC Data Sources" Or subk = "ODBC File DSN" Then
    Else

    'if we have a DSN that matches our current default selected DSN from TestPartner, then lets assume that we are going to use that
    'If subk = currentDB Then
    'cmbDSN.Text = currentDB
    'End If
    cmbDSN.Items.Add(subk)
    End If
    Next

    ReDim MyItems(cmbDSN.Items.Count - 1)
    Dim h As Int16

    'now save that collection in an array
    For Each temp In cmbDSN.Items
    MyItems(h) = temp
    h = h + 1
    Next

    'reset counter
    h = 0

    'loop through collection in combo box. find DBType, add to name of item
    For Each temp In cmbDSN.Items
    rootKey = Registry.LocalMachine
    rootKey = rootKey.OpenSubKey("SOFTWARE", True)
    rootKey = rootKey.OpenSubKey("ODBC", True)
    rootKey = rootKey.OpenSubKey("ODBC.INI", True)
    rootKey = rootKey.OpenSubKey(temp, True)
    Driver = rootKey.GetValue("Driver").ToString()
    Driver = Driver.ToLower()

    If Driver.Contains("odbcjt32.dll") Then
    DBType = "Access"
    ElseIf Driver.Contains("sqora32.dll") Then
    'to be found later
    DBType = "Oracle"
    ElseIf Driver.Contains("sqlncli.dll") Then
    DBType = "SQL Native Client"
    ElseIf Driver.Contains("sqlsrv32.dll") Then
    DBType = "SQL Server"
    Else
    DBType = "Other"
    End If
    MyItems(h) = temp + " = " + DBType
    h = h + 1
    Next

    'reset counter
    h = 0

    'clear combo box
    cmbDSN.Items.Clear()

    'loop through items and add them to the combo box
    For h = MyItems.GetLowerBound(0) To MyItems.GetUpperBound(0)
    cmbDSN.Items.Add(MyItems(h))
    Next

    End Sub


    This should help with VBA and the registry

    </pre><hr /> VBA + Registry

  3. #3
    Senior Member
    Join Date
    Aug 2008
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Can I grab the TestPartner database name?

    Forgot to mention that TP running DB is located at:

    Hibe: HKCU\Software\Compuware\TestParter\Login
    Key: Database
    -Steve

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

    Re: Can I grab the TestPartner database name?

    Thanks Steve. Unfortunately it looks like this registry setting only is set if I've logged in manually into that TestPartner database. So when running a batch file it won't set properly.

    But, it looks like this works:
    SystemInfo.TestPartnerDsn

 

 

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.34%
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 09:50 PM.

Copyright BetaSoft Inc.