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

sxl_bellysxl_belly Posts: 2
edited October 23, 2008 6:05AM in SQL Packager Previous Versions
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~!!!!

Comments

  • 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.)
    Software Developer
    Redgate Software
  • 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.
  • 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.
    Software Developer
    Redgate Software
  • 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?
  • 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.
    Software Developer
    Redgate Software
Sign In or Register to comment.