get MetastormDefault connection to use it in ADO.NET
Hi
I wonder if there is any possibility to retrieve sqlconnection object from MetastormDefault class e.g. to use it in ADO.Net and prevent opening new connection.
Comments
-
Hi Milosz,
For database connection objects other than MetastormDefault(), you can get the ConnectionString property of the object to create your Ado.Net connection. MetastormDefault() does not expose this property, so best practice would be to maintain an external store for these values.
If you absolutely must get the same connection string that the engine uses as MetastormDefault(), then you can scrape the registry (although this is unsupported). The basic idea is as follows:
(This may require you to copy the Microsoft.Win32 DLL to the custom DLL folders) ..\[InstallDirectory]\Metastorm\BPM\Deployment\CustomLib\ ..\[InstallDirectory]\Metastorm\BPM\Designer\CustomLib\ ..\[InstallDirectory]\Metastorm\BPM\Engine\dotnetbin using Microsoft.Win32; public string GetConnString() { return RegValue(RegistryHive.LocalMachine, "SOFTWARE\\Wow6432Node\\Metastorm\\e-work\\Engine\\Database Connectors\\SQL Server DBC", "DotNetConnection"); } public string RegValue(RegistryHive Hive, string Key, string ValueName) { RegistryKey objParent = null; RegistryKey objSubkey = null; string sAns = null; switch (Hive) { case RegistryHive.ClassesRoot: objParent = Registry.ClassesRoot; break; case RegistryHive.CurrentConfig: objParent = Registry.CurrentConfig; break; case RegistryHive.CurrentUser: objParent = Registry.CurrentUser; break; case RegistryHive.DynData: objParent = Registry.DynData; break; case RegistryHive.LocalMachine: objParent = Registry.LocalMachine; break; case RegistryHive.PerformanceData: objParent = Registry.PerformanceData; break; case RegistryHive.Users: objParent = Registry.Users; break; } try { objSubkey = objParent.OpenSubKey(Key); //if can't be found, object is not initialized if ((objSubkey != null)) { sAns = (string)objSubkey.GetValue(ValueName); } } catch (Exception ex) { return ex.ToString(); } return sAns; }
0 -
We are wondering if there is option to use sqlconnection used by engine, not connection string. If engine has some aways open connection is there any option to use it?
0
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 152 General Questions
- 148 Thrust Services
- 57 Developer Hackathon
- 37 Thrust Studio
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 190 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 10 XM Fax
- Follow Categories