How to get Pivotal Connection String

By judam

The C# code below shows us on how to build the trusted connection string from the registry stored by Pivotal.

using Microsoft.Win32;

 

private string GetConStringByPivotalSystem(string systemName)

{

    string pivotalKey =

            “Software\\Pivotal\\Relationship\\Connections\\”

            + systemName;

    string odbcKey = “SOFTWARE\\ODBC\\ODBC.INI\\”;

    string sODBC;

    string serverName;

    string dbName;

 

    RegistryKey key =

       Registry.LocalMachine.OpenSubKey(pivotalKey, true);

 

    sODBC = Convert.ToString(key.GetValue(“User Data”));

 

    odbcKey = odbcKey + sODBC;

    key = Registry.LocalMachine.OpenSubKey(odbcKey, true);

    serverName = Convert.ToString(key.GetValue(“Server”));

    dbName = Convert.ToString(key.GetValue(“Database”));

    return “Data Source=” +

                serverName + “;Initial Catalog=” +

                dbName + “;Integrated Security=SSPI;”;

}

Leave a Reply