Showing posts with label properties. Show all posts
Showing posts with label properties. Show all posts

Thursday, March 29, 2012

Getting a reference to a Script task in VB.net

I am trying to get a reference to a script task so I can manipulate it's properties. However I can't seem to figure it out? I have a reference to Microsoft.SqlServer.ManagedDTS and Microsoft.SqlServer.Dts.Design and based on BOL they show

Imports System

Imports System.Collections.Generic

Imports System.Text

Imports Microsoft.SqlServer.Dts.Runtime

Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask

Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask

Imports Microsoft.SqlServer.Dts.Runtime

But I get errors saying

Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask

Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask

can't be found? What do I need to reference or Import to be able to see the Tasks and/or Task types so I can convet InnerObject to a ScriptTask type and manipulate?

What am doing wrong?

Dim pkgPath As String = "C:\Program Files\\ETL\ODS\Policy\"Dim pkgName As String = "LoadOdsCountryCodes"

Dim pkg1 As String = pkgPath + pkgName + ".dtsx"

Dim pkg2 As String = pkgPath + pkgName + "2.dtsx"

Dim app As Application = New Application()

Dim pkg As Package = app.LoadPackage(pkg1, Nothing)

Dim x As Executable

For Each x In pkg.Executables

Dim t As TaskHost = CType(x, TaskHost)

If t.Name = "SCT Set Global Variables" Then

Dim sct As ? = ctype(t.InnerObject,?)

End If

Next

You cannot manipulate properties of objects in the package directly from script within the package. Period.

What you CAN do is put expressions on properties which affect them at execution-time.

-Jamie

|||

I am not trying to do it from within a package. this is outside of SSIS in the vb.net IDE.

I have figured it out.

Imports Microsoft.SqlServer.Dts.Runtime

Imports Microsoft.SqlServer.Dts.Tasks.ScriptTask

Module SSISPackage

Public Sub main()

Dim pkgPath As String = "C:\Program Files\Insurity\Reporting Decisions\ETL\ODS\Policy\"

Dim pkgName As String = "LoadOdsCountryCodes"

Dim pkg1 As String = pkgPath + pkgName + ".dtsx"

Dim pkg2 As String = pkgPath + pkgName + "2.dtsx"

Dim app As Application = New Application()

Dim pkg As Package = app.LoadPackage(pkg1, Nothing)

Dim x As Executable

For Each x In pkg.Executables

Dim t As TaskHost = CType(x, TaskHost)

If t.Name = "SCT Set Global Variables" Then

Dim sct As ScriptTask = CType(t.InnerObject, ScriptTask)

Dim cp As ScriptTaskCodeProvider = sct.CodeProvider

Dim Moniker As String = "dts://Scripts/" & sct.VsaProjectName & "/" & sct.VsaProjectName & ".vsaproj"

Dim code As String = cp.GetSourceCode(Moniker)

End If

Next

But still does not seem to show the user text added by the developer? Strange.

|||

I had to add a reference to:

Microsoft.SqlServer.ScriptTask

Microsoft.SqlServer.VSAHosting

to my project and then this would work:

Imports Microsoft.SqlServer.Dts.Tasks.ScriptTask

|||

Ah OK. Sorry, my bad!

Glad you got it working.

-Jamie

sql

Wednesday, March 21, 2012

Get/SetExecutionOptions question

Can Get/SetExecutionOptions really get/set all the Execution properties that
are available via Report Manager? As far as I can see I can set a report to
Live or Snapshot and set a schedule if Snapshot. How do I retrieve the
setting " Cache a temporary copy of the report. Expire copy of report after
a number of minutes" for example ? This comes back as
ExecutionSettingEnum.Live but I can't see how to get the number of minutes?
Same if the expiry is based on a schedule - it does not get populated when
Live. I need to script these settings but can't see how to do this?
--
Cheers,
JasIf execution is set to Live, use GetCacheOptions method to get expiration
definition:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_ak_3cq8.asp
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:%23FuGijFFFHA.2572@.tk2msftngp13.phx.gbl...
> Can Get/SetExecutionOptions really get/set all the Execution properties
> that are available via Report Manager? As far as I can see I can set a
> report to Live or Snapshot and set a schedule if Snapshot. How do I
> retrieve the setting " Cache a temporary copy of the report. Expire copy
> of report after a number of minutes" for example ? This comes back as
> ExecutionSettingEnum.Live but I can't see how to get the number of
> minutes? Same if the expiry is based on a schedule - it does not get
> populated when Live. I need to script these settings but can't see how to
> do this?
> --
> Cheers,
> Jas
>
>|||Perfect, I completely missed that method :-)
--
Cheers,
Jas
"Lev Semenets [MSFT]" <levs@.microsoft.com> wrote in message
news:OdPCASLFFHA.3972@.TK2MSFTNGP15.phx.gbl...
> If execution is set to Live, use GetCacheOptions method to get expiration
> definition:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_ak_3cq8.asp
> --
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> "Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
> news:%23FuGijFFFHA.2572@.tk2msftngp13.phx.gbl...
>> Can Get/SetExecutionOptions really get/set all the Execution properties
>> that are available via Report Manager? As far as I can see I can set a
>> report to Live or Snapshot and set a schedule if Snapshot. How do I
>> retrieve the setting " Cache a temporary copy of the report. Expire copy
>> of report after a number of minutes" for example ? This comes back as
>> ExecutionSettingEnum.Live but I can't see how to get the number of
>> minutes? Same if the expiry is based on a schedule - it does not get
>> populated when Live. I need to script these settings but can't see how to
>> do this?
>> --
>> Cheers,
>> Jas
>>
>

Friday, February 24, 2012

get properties of a relation with SQL - DMO

Hi,
I am going to gather information of the database objects and (after a bypass
– stored procedures) use the SQL-DMO.
What I get information of relations (constraints, foreign keys as you like) ?
I found only Chek and Key objects.
How can I get actions on insert and delete event (’no action’ or ’cascade’).
I get key objects (LPSQLDMOKEY) of a table object (LPSQLDMOTABLE) and it
have only functions
GetName(&bstrName);
GetReferencedTable(&bstrRefTable);
GetReferencedKey(&bstrRefKey);
GetKeyColumns(&lpKeyColumns);
GetReferencedColumns(&lpBaseColumns);
I have to know :
base table
referenced table
column in base table (foreign key column)
column in referenced table (primary key column)
action insert
action delete
The first way was stored procedures, I had give it up on column properties
(identity and pk property was not clear) .
Now I am come up to relations (through columns and indexes) and type more
code. :-)
One more way what I know is the OLEDB schemas.
Give me hope to exists a solution and not need to throw away my program! :-)
Thanks for any idea,
Imre
=?Utf-8?B?SW1yZSBBbWVudA==?= <ImreAment@.discussions.microsoft.com> wrote
in news:1DF30CA9-4855-482F-91AD-164E2C6BB621@.microsoft.com:

> Hi,
> I am going to gather information of the database objects and (after a
> bypass – stored procedures) use the SQL-DMO.
> What I get information of relations (constraints, foreign keys as you
> like) ? I found only Chek and Key objects.
> How can I get actions on insert and delete event (’no action’ or
> ’cascade’).
I assume you mean Insert and Delete Triggers. These are to be found in
the Triggers collection of the Table object.

> I get key objects (LPSQLDMOKEY) of a table object
> (LPSQLDMOTABLE) and it have only functions
> GetName(&bstrName);
> GetReferencedTable(&bstrRefTable);
> GetReferencedKey(&bstrRefKey);
> GetKeyColumns(&lpKeyColumns);
> GetReferencedColumns(&lpBaseColumns);
These are "property getters", e.g. GetName gets the Name property of the
object.

> I have to know :
> base table
> referenced table
> column in base table (foreign key column)
> column in referenced table (primary key column)
> action insert
> action delete
> The first way was stored procedures, I had give it up on column
> properties (identity and pk property was not clear) .
> Now I am come up to relations (through columns and indexes) and type
> more code. :-)
> One more way what I know is the OLEDB schemas.
> Give me hope to exists a solution and not need to throw away my
> program! :-)
I recommend that you look at the SQL-DMO object model in the SQL Server
2000 Books Online (which has active links) or
http://msdn2.microsoft.com/en-us/library/ms141100.aspx with no active
links :-(
However, you should note that DMO is deprecated in favour of SMO and may
be removed in some future version. However, SMO is not available in
versions prior to SQL Server 2005.

get properties of a relation with SQL - DMO

Hi,
I am going to gather information of the database objects and (after a bypass
– stored procedures) use the SQL-DMO.
What I get information of relations (constraints, foreign keys as you like)
?
I found only Chek and Key objects.
How can I get actions on insert and delete event (’no action’ or ’casc
ade’).
I get key objects (LPSQLDMOKEY) of a table object (LPSQLDMOTABLE) and it
have only functions
GetName(&bstrName);
GetReferencedTable(&bstrRefTable);
GetReferencedKey(&bstrRefKey);
GetKeyColumns(&lpKeyColumns);
GetReferencedColumns(&lpBaseColumns);
I have to know :
base table
referenced table
column in base table (foreign key column)
column in referenced table (primary key column)
action insert
action delete
The first way was stored procedures, I had give it up on column properties
(identity and pk property was not clear) .
Now I am come up to relations (through columns and indexes) and type more
code. :-)
One more way what I know is the OLEDB schemas.
Give me hope to exists a solution and not need to throw away my program! :-)
Thanks for any idea,
Imreexamnotes <ImreAment@.discussions.microsoft.com> wrote
in news:1DF30CA9-4855-482F-91AD-164E2C6BB621@.microsoft.com:

> Hi,
> I am going to gather information of the database objects and (after a
> bypass – stored procedures) use the SQL-DMO.
> What I get information of relations (constraints, foreign keys as you
> like) ? I found only Chek and Key objects.
> How can I get actions on insert and delete event (’no action’ or
> ’cascade’).
I assume you mean Insert and Delete Triggers. These are to be found in
the Triggers collection of the Table object.

> I get key objects (LPSQLDMOKEY) of a table object
> (LPSQLDMOTABLE) and it have only functions
> GetName(&bstrName);
> GetReferencedTable(&bstrRefTable);
> GetReferencedKey(&bstrRefKey);
> GetKeyColumns(&lpKeyColumns);
> GetReferencedColumns(&lpBaseColumns);
These are "property getters", e.g. GetName gets the Name property of the
object.

> I have to know :
> base table
> referenced table
> column in base table (foreign key column)
> column in referenced table (primary key column)
> action insert
> action delete
> The first way was stored procedures, I had give it up on column
> properties (identity and pk property was not clear) .
> Now I am come up to relations (through columns and indexes) and type
> more code. :-)
> One more way what I know is the OLEDB schemas.
> Give me hope to exists a solution and not need to throw away my
> program! :-)
I recommend that you look at the SQL-DMO object model in the SQL Server
2000 Books Online (which has active links) or
http://msdn2.microsoft.com/en-us/library/ms141100.aspx with no active
links :-(
However, you should note that DMO is deprecated in favour of SMO and may
be removed in some future version. However, SMO is not available in
versions prior to SQL Server 2005.

get properties of a relation with SQL - DMO

Hi,
I am going to gather information of the database objects and (after a bypass
â' stored procedures) use the SQL-DMO.
What I get information of relations (constraints, foreign keys as you like) ?
I found only Chek and Key objects.
How can I get actions on insert and delete event (â'no actionâ' or â'cascadeâ').
I get key objects (LPSQLDMOKEY) of a table object (LPSQLDMOTABLE) and it
have only functions
GetName(&bstrName);
GetReferencedTable(&bstrRefTable);
GetReferencedKey(&bstrRefKey);
GetKeyColumns(&lpKeyColumns);
GetReferencedColumns(&lpBaseColumns);
I have to know :
base table
referenced table
column in base table (foreign key column)
column in referenced table (primary key column)
action insert
action delete
The first way was stored procedures, I had give it up on column properties
(identity and pk property was not clear) .
Now I am come up to relations (through columns and indexes) and type more
code. :-)
One more way what I know is the OLEDB schemas.
Give me hope to exists a solution and not need to throw away my program! :-)
Thanks for any idea,
Imre=?Utf-8?B?SW1yZSBBbWVudA==?= <ImreAment@.discussions.microsoft.com> wrote
in news:1DF30CA9-4855-482F-91AD-164E2C6BB621@.microsoft.com:
> Hi,
> I am going to gather information of the database objects and (after a
> bypass â' stored procedures) use the SQL-DMO.
> What I get information of relations (constraints, foreign keys as you
> like) ? I found only Chek and Key objects.
> How can I get actions on insert and delete event (â'no actionâ' or
> â'cascadeâ').
I assume you mean Insert and Delete Triggers. These are to be found in
the Triggers collection of the Table object.
> I get key objects (LPSQLDMOKEY) of a table object
> (LPSQLDMOTABLE) and it have only functions
> GetName(&bstrName);
> GetReferencedTable(&bstrRefTable);
> GetReferencedKey(&bstrRefKey);
> GetKeyColumns(&lpKeyColumns);
> GetReferencedColumns(&lpBaseColumns);
These are "property getters", e.g. GetName gets the Name property of the
object.
> I have to know :
> base table
> referenced table
> column in base table (foreign key column)
> column in referenced table (primary key column)
> action insert
> action delete
> The first way was stored procedures, I had give it up on column
> properties (identity and pk property was not clear) .
> Now I am come up to relations (through columns and indexes) and type
> more code. :-)
> One more way what I know is the OLEDB schemas.
> Give me hope to exists a solution and not need to throw away my
> program! :-)
I recommend that you look at the SQL-DMO object model in the SQL Server
2000 Books Online (which has active links) or
http://msdn2.microsoft.com/en-us/library/ms141100.aspx with no active
links :-(
However, you should note that DMO is deprecated in favour of SMO and may
be removed in some future version. However, SMO is not available in
versions prior to SQL Server 2005.