Red Gate forums :: View topic - How to add scripts to C# package project
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 add scripts to C# package project

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



Joined: 23 May 2011
Posts: 3

PostPosted: Wed Aug 10, 2011 6:51 pm    Post subject: How to add scripts to C# package project Reply with quote

Hi there

Iím a newbie. I just want to know how to add a script to the C# Package project. I have some scripts that I have to run before the sync script produced by packager wizard.

Thanks
_________________
Israel
Back to top
View user's profile Send private message
james.billings



Joined: 16 Jun 2010
Posts: 1144
Location: My desk.

PostPosted: Thu Aug 11, 2011 8:33 pm    Post subject: Reply with quote

Thanks for your post.
The SQL that is created by packager is stored as resources in the C# project, and I don't think you can easily amend these. The generated application does support the /presql and /postsql commands though, so you can supply a .sql script as a commandline option when executing the built package.

If you wanted to incorporate the extra commands directly into your package when compiling, it's perhaps a little trickier and not something i've tried before.
A look at the project shows that the /presql and /postsql switches set a couple of properties in the PackageExecutor class. You'll see the Execute method in there calls:

Code:

RunSQLFile(PreSqlFile, "Running pre-processing script")


The RunSQLFile method is responsible for loading the commands from the file and then passing them to the "ExecuteSQLCommand" method, so i'd look at implementing something around this area to suit your needs - for instance running some commands hard-coded into the app.

Hope that helps.
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