How to generate a exe package for SQL script by using dll?

Packages and compresses schema and contents of SQL Server databases

Moderators: JonathanWatts, Chris Auckland, David Atkinson, david connell, Anu Deshpande, Michelle Taylor, james.billings, Marianne

How to generate a exe package for SQL script by using dll?

Postby sxl_belly » Fri Oct 17, 2008 4:07 am

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~!!!!
sxl_belly
 
Posts: 1
Joined: Fri Oct 17, 2008 3:58 am

Postby Michelle Taylor » Fri Oct 17, 2008 11:40 am

You can specify defaults for some of the details that the package asks for while creating the package, and then you can run the package itself with the /quiet switch (and other switches to fill in the rest of the details if necessary) to just use these defaults without prompting for anything.

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.)
Michelle Taylor
 
Posts: 529
Joined: Mon Oct 30, 2006 12:45 pm
Location: Red Gate Software

Postby sakthivenkatesh » Fri Oct 17, 2008 5:12 pm

FYI - myself and sxl_belly are working on the same requirement :) .

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.
sakthivenkatesh
 
Posts: 3
Joined: Fri Oct 17, 2008 5:00 pm

Postby Michelle Taylor » Tue Oct 21, 2008 11:21 am

If you look at the worked example in the Packager API help (http://help.red-gate.com/help/SQLPackag ... /index.htm) you'll find near the end of the file a function called AddPackagerProperties which shows you how to add the server and database name to your PackagerEngine object before you call Package to create the executable.

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.
Michelle Taylor
 
Posts: 529
Joined: Mon Oct 30, 2006 12:45 pm
Location: Red Gate Software

Postby sakthivenkatesh » Wed Oct 22, 2008 9:44 pm

Thanks for your suggestion.

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?
sakthivenkatesh
 
Posts: 3
Joined: Fri Oct 17, 2008 5:00 pm

Postby Michelle Taylor » Thu Oct 23, 2008 11:05 am

It ought to be PACKAGE_SERVER_NAME, but as there's no way of accessing it outside of the API, that might be broken.

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.
Michelle Taylor
 
Posts: 529
Joined: Mon Oct 30, 2006 12:45 pm
Location: Red Gate Software


Return to SQL Packager 6

Who is online

Users browsing this forum: No registered users and 0 guests