Red Gate forums :: View topic - How to generate a exe package for SQL script by using dll?
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Packager 6
SQL Packager 6 forum

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

Search in SQL Packager 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
sxl_belly



Joined: 17 Oct 2008
Posts: 1

PostPosted: Fri Oct 17, 2008 4:07 am    Post subject: How to generate a exe package for SQL script by using dll? Reply with quote

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~!!!!
Back to top
View user's profile Send private message
Michelle Taylor



Joined: 30 Oct 2006
Posts: 525
Location: Red Gate Software

PostPosted: Fri Oct 17, 2008 11:40 am    Post subject: Reply with quote

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.)
Back to top
View user's profile Send private message
sakthivenkatesh



Joined: 17 Oct 2008
Posts: 3

PostPosted: Fri Oct 17, 2008 5:12 pm    Post subject: Reply with quote

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

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.
Back to top
View user's profile Send private message
Michelle Taylor



Joined: 30 Oct 2006
Posts: 525
Location: Red Gate Software

PostPosted: Tue Oct 21, 2008 11:21 am    Post subject: Reply with quote

If you look at the worked example in the Packager API help (http://help.red-gate.com/help/SQLPackagerAPIv6/0/en/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.
Back to top
View user's profile Send private message
sakthivenkatesh



Joined: 17 Oct 2008
Posts: 3

PostPosted: Wed Oct 22, 2008 9:44 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Michelle Taylor



Joined: 30 Oct 2006
Posts: 525
Location: Red Gate Software

PostPosted: Thu Oct 23, 2008 11:05 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group