cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DavidAhl
Level 2

Add Sql script with Automation

I'm trying to add a couple of sql scripts with Automation objects from a little c# app. It looks something like this:
foreach (string scriptName in sqlScripts)
{
ISWiSQLConnection connection = getConnection();
ISWiSQLScript script = connection.AddSQLScript();

script.Name = scriptName;

}


First cycle runs fine. However, I've noticed that the script.Component property has been assigned with "SQLScriptComponent" and changing the name of the script is not reflected in the component.

Second cycle of the loop it crashes at AddSQLScript() with the message:
This key is already associated with an element of this collection
> ISWiAutomation.ISWiSQLScripts.Add
> ISWiAutomation.ISWiSQLConnection.AddSQLScript


I've tried creating a new component with a new name, assign it to the script and remove the old one (the "SQLScriptComponent") for every cycle of the loop. But the problem remains.

Any ideas?
Labels (1)
0 Kudos
(1) Reply
TheTraveler
Level 8

Honestly, I haven't tried what you are attempting to do. However, as an alternative that I know works, there is a way to run SQL Scripts from Install Shield (IS) Script code by creating ADO objects. There are plenty of examples that I and other IS Developers have posted on this forum. Feel free to take a look.
0 Kudos