Showing posts with label programmatically. Show all posts
Showing posts with label programmatically. Show all posts

Sunday, March 11, 2012

Add scripttask script programmatically

I'm building packages programmatically. I need to add a ScriptTask to my package and include the script code. The script task itself is easy to add. But I can't figure out how to add the script code to the task.

I found one post in this forum saying the trick is to use the PutSourceCode method of the StriptTaskCodeProvider class, but I can't figure out how to do that.

Can anyone provide a code sample of how this is done?

Thanks.

After looking into this more deeply I found that adding a Script Task is a large job and I opted for a simpler approach to my particular issue. A lot of code needs to be added into the package. You have to create a VSA project, then add the script code it contains. To see an example of what's required, open a .dtsx file containing a Script Task and look for the tag "ScriptProject Name", and examine the ProjectItems it contains.

In case it is of use to anyone in the future, here's what I came up with. This doesn't create both the project and the script code because I didn't go that far, but it shows you the references and objects you'll need to do that.

Add references to Microsoft.SqlServer.ScriptTask and Microsoft.SqlServer.VSAHosting.

Dim exe As Executable = _Package.Executables.Add("STOCK:ScriptTask")

Dim thTask As TaskHost = CType(exe, TaskHost)

thTask.Name = "MyScriptTask"

Dim st As ScriptTask = TryCast(thTask.InnerObject, ScriptTask)

dim Moniker as String = "dts://Scripts/" & st.VsaProjectName & "/" & st.VsaProjectName & ".vsaproj"

st.ReadWriteVariables = "Var1, Var2"

Dim sb As New StringBuilder

sb.AppendLine("'Microsoft SQL Server Integration Services Script Task")

'build your code here

'this inserts the code into the script task

st.CodeProvider.PutSourceCode(Moniker, sb.ToString)

Thursday, March 8, 2012

Add new user with web service

Hi there,
Would like to manage users (adding, deleting) and give them browsing rights
to reports programmatically, using the web service. Can't find the method
allowing me to do it anywhere.
Am I missing something ?
Cheers
ggThere are several methods depending on what you want to accomplish. Given a
user you can give them system level privledges using SetSystemPolicies() or
privledges on individual items using SetPolicies(). A policy is a mapping
of a user to a role. Roles are managed via
CreateRole()/SetRoleProperties/etc.. and define the specific privledges you
want to assign. For your purposes you might want to use the predefined
"Browser" role.
Jon Heide
SQL Server Reporting Services
----
Everything you need to know about SQL Server Reporting Services:
http://www.microsoft.com/sql/reporting/default.asp
----
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
----

Saturday, February 25, 2012

add entities to report model programmatically ?

Hi Friends
is it possible to add entities to a report model dynamically ,probably thru SOAP api ?
we've c# app and we want to be able to add entities dynamically .
Thanks for the helpNo, the only API's are for updating the entire model.|||Thanks BOB.
thats what i figured out finally. BUT i found a way of adding attributes to existing entities .am reading .smdl file using a c# program and adding a attribute under a specific entity.
if i re-publish the model everything worked fine as normal.

i need to do this as our clients want to report on "user defined tables" which we're not aware of when creating report model!
i have not tested my approach enough and i appreciate ur advise here. is there any better way of doing this.
Your advise really appreciated.
Thanks again|||That looks like your best option.|||

Thanks for the reply Bob.

Actually i was not sure before, now after ur post i've got some confidence to try this solution in real world. Thanks again :)