Using connection string defined in the service-center in an extension

Using connection string defined in the service-center in an extension

  
Is there any way to access connection string defined in the service-center in an extension by name ?
DBTransactionManager.Current.ConnectionString used OSRuntime user. 
Thanks.
Hi,

Check the RuntimePublic.Db API documentation.
It allows you to get a Transaction for correct database by getting the provider using the DatabaseAccess.ForExternalDatabase method.

See the examples in the help on how to use the API.

Regards,
João Rosado
Hi Joao,
             After looking into some outsytems generated code, It seems that following code is also working. 

            IDbTransaction trans = DBTransactionManager.Current.GetMainTransaction(connectionstringname);
            IDbCommand dbCommand = DBHelper.CreateCommand(trans);
            dbCommand.CommandText = spname;
            dbCommand.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter adp = new SqlDataAdapter();
            DataSet ds = new DataSet();
            ds = DBHelper.CreateAndFillDataSet(dbCommand, adp);

As per my understanding RuntimePublic.Db API is available only from version 9. Right ?

Regards

Yes, it is on 9+ only.
The usages of DBTransactionManager were all deprecated in 9.0 (and they were not actually documented as a officially supported API before).


Regards,
João Rosado

So Would this code snippet not work in version 9 ?  
Hi,

It will still work. (With a lot of deprecated compilation warnings)
But it can/will be removed on a future major version.

Regards,
João Rosado