Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: Dynamic MS Sql Connection String
Topic Summary: Is a dynamic connection string for ms sql possible in BPA
Created On: 06/30/2015 08:04 AM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Leonard Amabile, on Monday, July 6, 2015 12:14 PM

Answer:
The GetComputerName() function will not work in the MS SQL Data Link Properties. However, once you have created a connection string, you can replace portions with a variable or expression.


 06/30/2015 08:04 AM
User is offline View Users Profile Print this message

Author Icon
TonGordon
Journeyman (50-99)

Posts: 87
Joined: 05/17/2011

We have a goal in our organization of just changing the Agent on the Workflow and having that job run correctly on our dev/uat/prod lifecycle machines. I understand how to do that for disk references by using agent variables to handle the drive references for running programs and file references. But I'm having a little trouble having the connection string to our ms sql databases dynamically point to the correct database server based on the agent machine. When I build the task with no agent machine assigned not much choice comes up in terms of connection strings. When I go into the task through the Workflow editor with an Agent assigned I get the Agent Connection strings for that environment. But that makes me suspicious that if I changed the Agent in the Workflow whether it would work at runtime and switch over to the other database server. So is this possible and if so how do you specify the connection string so it can be dynamic? Or to put this question a little differently, if I had two identically named pre-defined connection strings (say defaultDBServer) on two agents, if I switched the Agents on the task, would that switch the database the task connected to?

 Category Survey
AutoMate BPA Server 9 version:
Windows version:


Edited: 07/01/2015 at 07:00 AM by TonGordon
 07/01/2015 12:34 PM
User is offline View Users Profile Print this message

Author Icon
Valentineo McGowan
HelpSystems

Posts: 766
Joined: 09/03/2013

Hello TonGordon,

Just to be clear are you asking either to have a task that runs a SQL Query or Stored Procedure (this would be a step/activity within the task) to now be modified to access a different database?
OR
Are you asking how an entire task or workflow can be set to execute on a different Agent?
OR
Yes, in both cases?

 Category Survey


-------------------------

Valentineo McGowan | Technical Consultant
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1 213.738.6966 | F: +1.213.738.7665
 07/02/2015 05:22 AM
User is offline View Users Profile Print this message

Author Icon
TonGordon
Journeyman (50-99)

Posts: 87
Joined: 05/17/2011

Valentineo, I want the entire task to be able to point at one database or another based on the agent that is set at run time. Someone in our organization showed me "SQL connection from a session" and I think that will do what I want. As long as we have you here, do you think getComputerName() will work in the 1. ... server name: box of the MS Sql Data Link properties?

 Category Survey
AutoMate BPA Server 9 version:
Windows version:
 07/04/2015 06:46 PM
User is offline View Users Profile Print this message

Author Icon
Leonard Amabile
HelpSystems

Posts: 5454
Joined: 05/15/2007

Answer Answer
The GetComputerName() function will not work in the MS SQL Data Link Properties. However, once you have created a connection string, you can replace portions with a variable or expression.




 Category Survey
AutoMate BPA Server 9 version:
Windows version:


-------------------------

Leonard Amabile | Director, Cross Platform Support
AutoMate | InterMapper | Skybot | Divisions of HelpSystems
T: +1.213.738.1700 | F: +1.213.738.7665
 07/08/2015 12:22 PM
User is offline View Users Profile Print this message

Author Icon
TonGordon
Journeyman (50-99)

Posts: 87
Joined: 05/17/2011

Did something kind of neat with this later. Not everyone would sync their databases with their agent machines but we did it that way. So in the code attached below I set the variable SQLSERVER to getComputerName() . Then for the SQL Session database command it let me put %SQLSERVER% in for the server name of the SQL Session. Can't show the setting of the SQL Session because it obfuscates it. But this is kind of neat functionality.

 Category Survey
AutoMate BPA Server 9 version:
Windows version:



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)
Statistics
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 5551 on 01/08/2018 at 11:11 AM.
There are currently 2126 guests browsing this forum, which makes a total of 2126 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2020 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog