How to generate a exe package for SQL script by using dll?
sxl_belly
Posts: 2
I want to generate a exe package for SQL script, not to create a database.
I don't know how to use the dll of RedGate.SQLPackager.Engine.
and When I run the package [exe], it asks me for database credentials where the script has to be executed. can we by pass this step [by hardcoding these details inside c# code]?
who can give me the sample? Thanks a lot~!!!!
I don't know how to use the dll of RedGate.SQLPackager.Engine.
and When I run the package [exe], it asks me for database credentials where the script has to be executed. can we by pass this step [by hardcoding these details inside c# code]?
who can give me the sample? Thanks a lot~!!!!
Comments
If you tell me what method you using to create the package (the GUI, the command line, the SDK), I can give you more advice on how to set the default details for the package.
(If you want to send someone an exe that they can just run without it prompting them for anything, you could send them the package and a batch file to run it with the appropriate command line switches.)
Redgate Software
Now coming back to your question, We are using SDK to create the package using c# application. Let us know how to set the following default details for the package without prompting the user.
1) Upgrade the existing database.
2) database name - 'TESTDATA'
3) Authentication - Windows
4) Server name - MachineName\LOGISTICS [where machine name might vary for each user, LOGISTICS is constant instance]
If you want to send someone an exe that they can just run without it prompting them for anything, you could send them the package and a batch file to run it with the appropriate command line switches - This is our exact reuirement. Let me know how i can create this exe using SDK.
our idea is to create and schedule a C# application using SDK which does the following
1) compare databases,
2) create synchorinzation script,
3) create a package for the script,
4) send mail to the users attaching the package.
This is currently being done manually on a weekly basis which we are trying to automate.
Thanks,
SakthiVenkatesh.
You'll still have to either ensure they run the correct command line (i.e. one with /quiet in it) or provide a batch file containing the correct command line to make sure it doesn't prompt them, though. This means you'll need to send them two files, one being the executable, one being a text file with the .bat extension containing the name of the executable and the /quiet switch, and get them to run the .bat file.
Redgate Software
I am able to specify DatabaseName/upgradedatabase using the below piece of code. But how do i default the server name? What is the property name for Server [PACKAGE_SERVER_NAME didnt work]?
engine.AddProperty("PACKAGE_UPGRADE_DATABASE", Convert.ToString(isUpgrade));
engine.AddProperty("PACKAGE_DATABASE_NAME", "SPECTRUMDATA");
Also, i would like to specify /quiet switch programmatically - let me know how that can be done?
There also isn't a way of specifying /quiet to the exe other than passing it the parameter.
I'm afraid the best workaround at the moment is to write out from your program a batch file which runs the package with the right switches (/server:SERVERNAME and /quiet) and send that and the exe out, instructing the user to run the batch file and not the exe.
We'll look into fixing the PACKAGE_SERVER_NAME for the next version.
Redgate Software