Hello,
I use Postgres DB, database activities, and ODBC 32 to create a connection.
How can I store the DB credentials, connection string, port, etc information in assets and how can I use those assets in my workflow?
You can store them as credential variables and string variables depending on it is secret field or common field
Get assets and get credentials will get data from assets
Now coming to using in the connection string…use placeholders in the string and use replace activities or use string.format…both would work
Connectionstrinf Eg - "datasource-<DS>;provider-<PR>".Replace("<DS>",str_AssetValue).Replace("<PS>",str_ProviderFromAsset)
Using string.format - String.Format("datasource-{0};provider-{1}",str_AssetValue,str_ProviderFromAsset)
Both wold work
Use the above methods with actual values in your connection string
Cheers
@Anil_G
below is my connection string
"Dsn=PostgreSQL35W;database=my_botdb;server=10.199.20.70;port=5875;uid=bot_user;pwd=NpM%2623DG%yJqK7;sslmode=disable;readonly=0;protocol=7.4;fakeoidindex=0;showoidcolumn=0;rowversioning=0;showsystemtables=0;fetch=100;socket=4096;unknownsizes=0;maxvarcharsize=255;maxlongvarcharsize=8190;debug=0;commlog=0;optimizer=0;ksqo=1;usedeclarefetch=0;textaslongvarchar=1;unknownsaslongvarchar=0;boolsaschar=1;parse=0;cancelasfreestmt=0;extrasystableprefixes=dd_;lfconversion=1;updatablecursors=1;disallowpremature=0;trueisminus1=0;bi=0;byteaaslongvarbinary=0;useserversideprepare=0;lowercaseidentifier=0;gssauthusegss=0;xaopt=1"
and
Provider name Is:
“System.Data.Odbc”
How can I separate username and password in connection string.
Try this
"Dsn=PostgreSQL35W;database=my_botdb;server=10.199.20.70;port=5875;uid=" + username + ";pwd=" + password + ";sslmode=disable;readonly=0;protocol=7.4;fakeoidindex=0;showoidcolumn=0;rowversioning=0;showsystemtables=0;fetch=100;socket=4096;unknownsizes=0;maxvarcharsize=255;maxlongvarcharsize=8190;debug=0;commlog=0;optimizer=0;ksqo=1;usedeclarefetch=0;textaslongvarchar=1;unknownsaslongvarchar=0;boolsaschar=1;parse=0;cancelasfreestmt=0;extrasystableprefixes=dd_;lfconversion=1;updatablecursors=1;disallowpremature=0;trueisminus1=0;bi=0;byteaaslongvarbinary=0;useserversideprepare=0;lowercaseidentifier=0;gssauthusegss=0;xaopt=1"
Here password and username are variables
Cheers
Thank you @Anil_G . The above logic has worked.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.