Showing posts with label connection. Show all posts
Showing posts with label connection. Show all posts

Friday, March 30, 2012

load files

the connection string in my application daynamic ..changed by changing the development environmet ..how can i load a data from file to sql server destination without hard coded the connection

thx

hi,

You could use xml files, registry entries or sql tables in order to save these parameters. (Package configurations when you click on the right mouse button) and then load them on demand.

|||Many links regarding package configurations can be found here: http://www.google.com/search?hl=en&q=ssis+package+configurations|||

Begin here: http://msdn2.microsoft.com/en-us/library/ms137592.aspx

load files

the connection string in my application daynamic ..changed by changing the development environmet ..how can i load a data from file to sql server destination without hard coded the connection

thx

hi,

You could use xml files, registry entries or sql tables in order to save these parameters. (Package configurations when you click on the right mouse button) and then load them on demand.

|||Many links regarding package configurations can be found here: http://www.google.com/search?hl=en&q=ssis+package+configurations|||

Begin here: http://msdn2.microsoft.com/en-us/library/ms137592.aspx

Wednesday, March 28, 2012

Load Balancer and Connection Pooling

Guys,

We have 2 main database servers, with our clients accessing either one DB or another via a website click. Our application, in the background, chooses randomly, which server to connect to. This approach achieves simulated load balancing.

For efficiency purposes, we also have the application manage connection pooling.

Recently, we realized that our current "simulated load balancing" is not good enough, as it blindly chooses which server to connect to, without considering the current workload of that server. We are now considering to acquire a load balancer [i.e. hardware piece] so that the load is balanced more wisely, by it. Our only concern is connection pooling. Will connection pooling still work with the new, proposed topology [i.e. applications sit to the left of the load balancer and the db servers to the right of it, with the load balancer in the middle].

If anyone has had any experience with this and could share or give advice, it would be appreciated.

Thanks a lot!Each connection will be bound to one specific server. What you can do however is having a timeout value associated with each connection, letting it live for some 30 seconds or so. In this way you can ensure that the load is balanced, while still limiting the number of connections made to the SQL Server. Please remember to include logic to reconect if you don't get an answer on an active connection :)|||Thanks for the suggestion roac!

Wednesday, March 21, 2012

ListenOn connection '1433' is already in use.

Hi, all.
SQL7SP4
2-node Acitve-Active Clustered
This morning, SQL Server stopped accepting connections. Here is excerpt from
Event Log and SQL Error Log.
++++++++++++++++++++++++++++++++++++++++++++++++++
Event Log
7/28/03 02:24:53AM
Reservation of cluster disk 'Disk X:' has been lost. Please check your
system and disk configuration.
Event Log
7/28/03 02:24:53AM
Cluster disk resource 'Disk X:' did not respond to a SCSI inquiry command.
Event Log
7/28/03 02:24:54AM
Cluster resource 'Disk X:' failed.
Shortly after,
SQL Error Log 7/28/03 02:25:21AM
SQL Server is terminating due to 'stop' request from Service Control
Manager.
When SQL Server tried to come back up again at 7/28/03 02:25:42AM such error
was reported:
ListenOn connection '1433' is already in use.
++++++++++++++++++++++++++++++++++++++++++++++++++++++
Anyone in similar situation? Why it doesn't fail to another node? Why
complaning the port was taken if re-started on the same node?
Any info is appreciated.
Wenleiwe got similar situation this morning:
Error: 17826, Severity: 18, State: 2
Could not set up ListenOn connection '1433'..
Operating system error 10093., Either the application has not called
WSAStartup, or WSAStartup failed.
We are on SQL7 SP4 cluster, does SQL70-KB815495-v7.00.1094-ENU.exe will fix
the problem?
Thank you.
Kun
"Wenlei Fang" <wfang@.jasc.com> wrote in message
news:um3ebfUVDHA.2352@.TK2MSFTNGP12.phx.gbl...
> Hi, all.
> SQL7SP4
> 2-node Acitve-Active Clustered
> This morning, SQL Server stopped accepting connections. Here is excerpt
from
> Event Log and SQL Error Log.
> ++++++++++++++++++++++++++++++++++++++++++++++++++
> Event Log
> 7/28/03 02:24:53AM
> Reservation of cluster disk 'Disk X:' has been lost. Please check your
> system and disk configuration.
> Event Log
> 7/28/03 02:24:53AM
> Cluster disk resource 'Disk X:' did not respond to a SCSI inquiry command.
> Event Log
> 7/28/03 02:24:54AM
> Cluster resource 'Disk X:' failed.
> Shortly after,
> SQL Error Log 7/28/03 02:25:21AM
> SQL Server is terminating due to 'stop' request from Service Control
> Manager.
> When SQL Server tried to come back up again at 7/28/03 02:25:42AM such
error
> was reported:
> ListenOn connection '1433' is already in use.
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Anyone in similar situation? Why it doesn't fail to another node? Why
> complaning the port was taken if re-started on the same node?
> Any info is appreciated.
> Wenlei
>sql

Monday, February 20, 2012

List all your connection managers

Hello,
I'm building a custom task which has a property ConnectionManager which obviously allows you to select which connection manager you're goinng to use.

I know how to get the list of connection managers but how do I make them appear in a combo-box in the properties pane? Anyone got some code for that? Hopefully this is fairly trivial for you developer types out there.

Thanks
JamieI believe that the key is the TypeConverter property of property objects.
If you were talking about a custom property in the Data Flow (which I realize is not your question) whose values came from an enumeration, using TypeConverter would both constrain the value of the property to an enumeration value, and tell the editor to display available values from the enumeration. From BOL (again, on the Data Flow, but I see that TypeConverter is available on other SSIS property objects):

You can limit users to selecting a custom property value from an enumeration by using the TypeConverter property, as shown in the following example, which assumes that you have defined a public enumeration named MyValidValues:

C#
 IDTSCustomProperty90 customProperty = outputColumn.CustomPropertyCollection.New(); 
customProperty.Name = "My Custom Property"; 
// This line associates the type with the custom property. 
customProperty.TypeConverter = typeof(MyValidValues).AssemblyQualifiedName; 
// Now you can use the enumeration values directly. 
customProperty.Value = MyValidValues.ValueOne; 

TR>
Visual Basic
 Dim customProperty As IDTSCustomProperty90 = outputColumn.CustomPropertyCollection.New 
customProperty.Name = "My Custom Property" 
' This line associates the type with the custom property. 
customProperty.TypeConverter = GetType(MyValidValues).AssemblyQualifiedName 
' Now you can use the enumeration values directly. 
customProperty.Value = MyValidValues.ValueOne

For more information, see "Generalized Type Conversion" and "Implementing a Type Converter" in the MSDN Library.

|||

To get rich behaviour such as list of connections, with <New Connection> option that fires the new conn dialog when selected, you need to go for a UITypeEditor.



Editor(typeof(DtsInputTypeEditor), typeof(System.Drawing.Design.UITypeEditor))
public string MyConnection
{
blah blah
}

You would need to create the DtsInputTypeEditor class, inheriting from UITypeEditor.


public sealed class DtsInputTypeEditor : UITypeEditor, IDisposable
{
blah blah
}

Overriding EditValue of UITypeEditor allows you grab the IWindowsFormsEditorService and throw up your editor control. Mine is a simple control which inherits from ListBox. In the editor control you can then capture the click event and test for <New Conn> and do what you need to do.

You could probably use a type convereter for a simples list and no new functions. Some articles I had gathered to help me.

Getting the Most Out of the .NET Framework PropertyGrid Control
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp)

Make Your Components Really RAD with Visual Studio .NET Property Browser
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vsnetpropbrow.asp)

Customized display of collection data in a PropertyGrid - The Code Project - C# Controls
(http://www.codeproject.com/cs/miscctrl/customizingcollectiondata.asp)

|||

If you just want to show list of existing connections, I think coding TypeConverter is much simpler than UITypeEditor. You just need to subclass TypeConverter and implement several functions: GetStandardValuesSupported() should return true, and GetStandardValues() should return list of connection manager names. Property panel will show list returned by GetStandardValues() in drop down box.

UITypeEditor gives you more control and more opportunity to implement custom behavior, but also requires more coding.

|||I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.|||

<BarefacedCheek>
Has anyone got the code that uses TypeConverter to provide a list of your connection managers in a combo box in the properties pane for a custom task? It'd save me an *awful* lot of work in working it out for myself if I could just nab someone else's!!

For example, in


GetStandardValues(...)

in my class that inherits from TypeConverter I need to get a list of connection managers in the task. How on earth do I do that?

Here's what I have already which is quite frankly nothing at all:


public class ConnectionManagerList : TypeConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}

public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
StandardValuesCollection connManList;

//What goes in here?

return connManList;
}
}


Thanks
Jamie
</BarefacedCheek>

|||

Use "context.Instance" to get your class for the property. From that you need to get the Connections collection, which depends on what the class is. Loop the connections and assign to the values collection. Job done. What your class is and how you expose the connections collection is the thinking bit.

|||I'm having some trouble with this. I have a breakpoint in the debugger, and when I view context.Instance, it is a Microsoft.DataTransformationServices.PipelineComponentMetadata class. I can't find any documentation on that class, and it doesn't seem to implement Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSComponentMetaData90, which is what I would have expected. What is context.Instance supposed to be?|||

The Instance will be whatever is parenting the grid. Looks like this is for a pipeline component, and that will differ from a task for example.

If you want a copy of IDTSComponentMetaData90, then PipelineComponentMetadata appears to have a property DtsComponentMetadata of type IDTSComponentMetaData90.

|||When I try to use the PipelineComponentMetadata object, it is giving me a compiler error, saying that the class is inaccessible :(|||

To get list of all connections managers, use IDtsConnectionService service. It is a public interface in Microsoft.SqlServer.Dts.Design and is documented in Books Online. It can be obtained from appropriate service provider.

PipelineComponentMetadata class is internal implementation details of the designer, don't use it.

|||Thanks Michael. Is there any way to get the output, input, and metadata collections? What I really need for the component I am working on is a list of the External Metadata columns for the first (only) input collection.|||

Where does your code live?

If this is UI Type Editor, you get ITypeDescriptorContext which gives you PropertyDescriptor. You can get the property value from it.

|||

Adam Tybor wrote:

I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.

Returning to this after a few months away...

Good stuff Adam. And that actually works really well for what I want to do.

However, I don't like the displaying of the ID rather than the name so I might decide to go down the UITypeEditor route instead.

-Thanks

Jamie

|||

Adam Tybor wrote:

I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.

Returning to this after a few months away...

Good stuff Adam. And that actually works really well for what I want to do.

However, I don't like the displaying of the ID rather than the name so I might decide to go down the UITypeEditor route instead.

-Thanks

Jamie

List all your connection managers

Hello,
I'm building a custom task which has a property ConnectionManager which obviously allows you to select which connection manager you're goinng to use.

I know how to get the list of connection managers but how do I make them appear in a combo-box in the properties pane? Anyone got some code for that? Hopefully this is fairly trivial for you developer types out there.

Thanks
JamieI believe that the key is the TypeConverter property of property objects.
If you were talking about a custom property in the Data Flow (which I realize is not your question) whose values came from an enumeration, using TypeConverter would both constrain the value of the property to an enumeration value, and tell the editor to display available values from the enumeration. From BOL (again, on the Data Flow, but I see that TypeConverter is available on other SSIS property objects):

You can limit users to selecting a custom property value from an enumeration by using the TypeConverter property, as shown in the following example, which assumes that you have defined a public enumeration named MyValidValues:

C#
 IDTSCustomProperty90 customProperty = outputColumn.CustomPropertyCollection.New(); 
customProperty.Name = "My Custom Property"; 
// This line associates the type with the custom property. 
customProperty.TypeConverter = typeof(MyValidValues).AssemblyQualifiedName; 
// Now you can use the enumeration values directly. 
customProperty.Value = MyValidValues.ValueOne; 

TR>
Visual Basic
 Dim customProperty As IDTSCustomProperty90 = outputColumn.CustomPropertyCollection.New 
customProperty.Name = "My Custom Property" 
' This line associates the type with the custom property. 
customProperty.TypeConverter = GetType(MyValidValues).AssemblyQualifiedName 
' Now you can use the enumeration values directly. 
customProperty.Value = MyValidValues.ValueOne

For more information, see "Generalized Type Conversion" and "Implementing a Type Converter" in the MSDN Library.

|||

To get rich behaviour such as list of connections, with <New Connection> option that fires the new conn dialog when selected, you need to go for a UITypeEditor.



Editor(typeof(DtsInputTypeEditor), typeof(System.Drawing.Design.UITypeEditor))
public string MyConnection
{
blah blah
}

You would need to create the DtsInputTypeEditor class, inheriting from UITypeEditor.


public sealed class DtsInputTypeEditor : UITypeEditor, IDisposable
{
blah blah
}

Overriding EditValue of UITypeEditor allows you grab the IWindowsFormsEditorService and throw up your editor control. Mine is a simple control which inherits from ListBox. In the editor control you can then capture the click event and test for <New Conn> and do what you need to do.

You could probably use a type convereter for a simples list and no new functions. Some articles I had gathered to help me.

Getting the Most Out of the .NET Framework PropertyGrid Control
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp)

Make Your Components Really RAD with Visual Studio .NET Property Browser
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vsnetpropbrow.asp)

Customized display of collection data in a PropertyGrid - The Code Project - C# Controls
(http://www.codeproject.com/cs/miscctrl/customizingcollectiondata.asp)

|||

If you just want to show list of existing connections, I think coding TypeConverter is much simpler than UITypeEditor. You just need to subclass TypeConverter and implement several functions: GetStandardValuesSupported() should return true, and GetStandardValues() should return list of connection manager names. Property panel will show list returned by GetStandardValues() in drop down box.

UITypeEditor gives you more control and more opportunity to implement custom behavior, but also requires more coding.

|||I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.|||

<BarefacedCheek>
Has anyone got the code that uses TypeConverter to provide a list of your connection managers in a combo box in the properties pane for a custom task? It'd save me an *awful* lot of work in working it out for myself if I could just nab someone else's!!

For example, in


GetStandardValues(...)

in my class that inherits from TypeConverter I need to get a list of connection managers in the task. How on earth do I do that?

Here's what I have already which is quite frankly nothing at all:


public class ConnectionManagerList : TypeConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}

public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
StandardValuesCollection connManList;

//What goes in here?

return connManList;
}
}


Thanks
Jamie
</BarefacedCheek>

|||

Use "context.Instance" to get your class for the property. From that you need to get the Connections collection, which depends on what the class is. Loop the connections and assign to the values collection. Job done. What your class is and how you expose the connections collection is the thinking bit.

|||I'm having some trouble with this. I have a breakpoint in the debugger, and when I view context.Instance, it is a Microsoft.DataTransformationServices.PipelineComponentMetadata class. I can't find any documentation on that class, and it doesn't seem to implement Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSComponentMetaData90, which is what I would have expected. What is context.Instance supposed to be?|||

The Instance will be whatever is parenting the grid. Looks like this is for a pipeline component, and that will differ from a task for example.

If you want a copy of IDTSComponentMetaData90, then PipelineComponentMetadata appears to have a property DtsComponentMetadata of type IDTSComponentMetaData90.

|||When I try to use the PipelineComponentMetadata object, it is giving me a compiler error, saying that the class is inaccessible :(|||

To get list of all connections managers, use IDtsConnectionService service. It is a public interface in Microsoft.SqlServer.Dts.Design and is documented in Books Online. It can be obtained from appropriate service provider.

PipelineComponentMetadata class is internal implementation details of the designer, don't use it.

|||Thanks Michael. Is there any way to get the output, input, and metadata collections? What I really need for the component I am working on is a list of the External Metadata columns for the first (only) input collection.|||

Where does your code live?

If this is UI Type Editor, you get ITypeDescriptorContext which gives you PropertyDescriptor. You can get the property value from it.

|||

Adam Tybor wrote:

I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.

Returning to this after a few months away...

Good stuff Adam. And that actually works really well for what I want to do.

However, I don't like the displaying of the ID rather than the name so I might decide to go down the UITypeEditor route instead.

-Thanks

Jamie

|||

Adam Tybor wrote:

I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.

Returning to this after a few months away...

Good stuff Adam. And that actually works really well for what I want to do.

However, I don't like the displaying of the ID rather than the name so I might decide to go down the UITypeEditor route instead.

-Thanks

Jamie

List all your connection managers

Hello,
I'm building a custom task which has a property ConnectionManager which obviously allows you to select which connection manager you're goinng to use.

I know how to get the list of connection managers but how do I make them appear in a combo-box in the properties pane? Anyone got some code for that? Hopefully this is fairly trivial for you developer types out there.

Thanks
JamieI believe that the key is the TypeConverter property of property objects.
If you were talking about a custom property in the Data Flow (which I realize is not your question) whose values came from an enumeration, using TypeConverter would both constrain the value of the property to an enumeration value, and tell the editor to display available values from the enumeration. From BOL (again, on the Data Flow, but I see that TypeConverter is available on other SSIS property objects):

You can limit users to selecting a custom property value from an enumeration by using the TypeConverter property, as shown in the following example, which assumes that you have defined a public enumeration named MyValidValues:

C#
 IDTSCustomProperty90 customProperty = outputColumn.CustomPropertyCollection.New(); 
customProperty.Name = "My Custom Property"; 
// This line associates the type with the custom property. 
customProperty.TypeConverter = typeof(MyValidValues).AssemblyQualifiedName; 
// Now you can use the enumeration values directly. 
customProperty.Value = MyValidValues.ValueOne; 

TR>
Visual Basic
 Dim customProperty As IDTSCustomProperty90 = outputColumn.CustomPropertyCollection.New 
customProperty.Name = "My Custom Property" 
' This line associates the type with the custom property. 
customProperty.TypeConverter = GetType(MyValidValues).AssemblyQualifiedName 
' Now you can use the enumeration values directly. 
customProperty.Value = MyValidValues.ValueOne

For more information, see "Generalized Type Conversion" and "Implementing a Type Converter" in the MSDN Library.

|||

To get rich behaviour such as list of connections, with <New Connection> option that fires the new conn dialog when selected, you need to go for a UITypeEditor.



Editor(typeof(DtsInputTypeEditor), typeof(System.Drawing.Design.UITypeEditor))
public string MyConnection
{
blah blah
}

You would need to create the DtsInputTypeEditor class, inheriting from UITypeEditor.


public sealed class DtsInputTypeEditor : UITypeEditor, IDisposable
{
blah blah
}

Overriding EditValue of UITypeEditor allows you grab the IWindowsFormsEditorService and throw up your editor control. Mine is a simple control which inherits from ListBox. In the editor control you can then capture the click event and test for <New Conn> and do what you need to do.

You could probably use a type convereter for a simples list and no new functions. Some articles I had gathered to help me.

Getting the Most Out of the .NET Framework PropertyGrid Control
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp)

Make Your Components Really RAD with Visual Studio .NET Property Browser
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vsnetpropbrow.asp)

Customized display of collection data in a PropertyGrid - The Code Project - C# Controls
(http://www.codeproject.com/cs/miscctrl/customizingcollectiondata.asp)

|||

If you just want to show list of existing connections, I think coding TypeConverter is much simpler than UITypeEditor. You just need to subclass TypeConverter and implement several functions: GetStandardValuesSupported() should return true, and GetStandardValues() should return list of connection manager names. Property panel will show list returned by GetStandardValues() in drop down box.

UITypeEditor gives you more control and more opportunity to implement custom behavior, but also requires more coding.

|||I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.|||

<BarefacedCheek>
Has anyone got the code that uses TypeConverter to provide a list of your connection managers in a combo box in the properties pane for a custom task? It'd save me an *awful* lot of work in working it out for myself if I could just nab someone else's!!

For example, in


GetStandardValues(...)

in my class that inherits from TypeConverter I need to get a list of connection managers in the task. How on earth do I do that?

Here's what I have already which is quite frankly nothing at all:


public class ConnectionManagerList : TypeConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}

public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
StandardValuesCollection connManList;

//What goes in here?

return connManList;
}
}


Thanks
Jamie
</BarefacedCheek>

|||

Use "context.Instance" to get your class for the property. From that you need to get the Connections collection, which depends on what the class is. Loop the connections and assign to the values collection. Job done. What your class is and how you expose the connections collection is the thinking bit.

|||I'm having some trouble with this. I have a breakpoint in the debugger, and when I view context.Instance, it is a Microsoft.DataTransformationServices.PipelineComponentMetadata class. I can't find any documentation on that class, and it doesn't seem to implement Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSComponentMetaData90, which is what I would have expected. What is context.Instance supposed to be?|||

The Instance will be whatever is parenting the grid. Looks like this is for a pipeline component, and that will differ from a task for example.

If you want a copy of IDTSComponentMetaData90, then PipelineComponentMetadata appears to have a property DtsComponentMetadata of type IDTSComponentMetaData90.

|||When I try to use the PipelineComponentMetadata object, it is giving me a compiler error, saying that the class is inaccessible :(|||

To get list of all connections managers, use IDtsConnectionService service. It is a public interface in Microsoft.SqlServer.Dts.Design and is documented in Books Online. It can be obtained from appropriate service provider.

PipelineComponentMetadata class is internal implementation details of the designer, don't use it.

|||Thanks Michael. Is there any way to get the output, input, and metadata collections? What I really need for the component I am working on is a list of the External Metadata columns for the first (only) input collection.|||

Where does your code live?

If this is UI Type Editor, you get ITypeDescriptorContext which gives you PropertyDescriptor. You can get the property value from it.

|||

Adam Tybor wrote:

I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.

Returning to this after a few months away...

Good stuff Adam. And that actually works really well for what I want to do.

However, I don't like the displaying of the ID rather than the name so I might decide to go down the UITypeEditor route instead.

-Thanks

Jamie

|||

Adam Tybor wrote:

I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.

Returning to this after a few months away...

Good stuff Adam. And that actually works really well for what I want to do.

However, I don't like the displaying of the ID rather than the name so I might decide to go down the UITypeEditor route instead.

-Thanks

Jamie

List all your connection managers

Hello,
I'm building a custom task which has a property ConnectionManager which obviously allows you to select which connection manager you're goinng to use.

I know how to get the list of connection managers but how do I make them appear in a combo-box in the properties pane? Anyone got some code for that? Hopefully this is fairly trivial for you developer types out there.

Thanks
JamieI believe that the key is the TypeConverter property of property objects.
If you were talking about a custom property in the Data Flow (which I realize is not your question) whose values came from an enumeration, using TypeConverter would both constrain the value of the property to an enumeration value, and tell the editor to display available values from the enumeration. From BOL (again, on the Data Flow, but I see that TypeConverter is available on other SSIS property objects):

You can limit users to selecting a custom property value from an enumeration by using the TypeConverter property, as shown in the following example, which assumes that you have defined a public enumeration named MyValidValues:

C#
 IDTSCustomProperty90 customProperty = outputColumn.CustomPropertyCollection.New(); 
customProperty.Name = "My Custom Property"; 
// This line associates the type with the custom property. 
customProperty.TypeConverter = typeof(MyValidValues).AssemblyQualifiedName; 
// Now you can use the enumeration values directly. 
customProperty.Value = MyValidValues.ValueOne; 

TR>

Visual Basic
 Dim customProperty As IDTSCustomProperty90 = outputColumn.CustomPropertyCollection.New 
customProperty.Name = "My Custom Property" 
' This line associates the type with the custom property. 
customProperty.TypeConverter = GetType(MyValidValues).AssemblyQualifiedName 
' Now you can use the enumeration values directly. 
customProperty.Value = MyValidValues.ValueOne

For more information, see "Generalized Type Conversion" and "Implementing a Type Converter" in the MSDN Library.

|||

To get rich behaviour such as list of connections, with <New Connection> option that fires the new conn dialog when selected, you need to go for a UITypeEditor.



Editor(typeof(DtsInputTypeEditor), typeof(System.Drawing.Design.UITypeEditor))
public string MyConnection
{
blah blah
}

You would need to create the DtsInputTypeEditor class, inheriting from UITypeEditor.


public sealed class DtsInputTypeEditor : UITypeEditor, IDisposable
{
blah blah
}

Overriding EditValue of UITypeEditor allows you grab the IWindowsFormsEditorService and throw up your editor control. Mine is a simple control which inherits from ListBox. In the editor control you can then capture the click event and test for <New Conn> and do what you need to do.

You could probably use a type convereter for a simples list and no new functions. Some articles I had gathered to help me.

Getting the Most Out of the .NET Framework PropertyGrid Control
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp)

Make Your Components Really RAD with Visual Studio .NET Property Browser
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vsnetpropbrow.asp)

Customized display of collection data in a PropertyGrid - The Code Project - C# Controls
(http://www.codeproject.com/cs/miscctrl/customizingcollectiondata.asp)

|||

If you just want to show list of existing connections, I think coding TypeConverter is much simpler than UITypeEditor. You just need to subclass TypeConverter and implement several functions: GetStandardValuesSupported() should return true, and GetStandardValues() should return list of connection manager names. Property panel will show list returned by GetStandardValues() in drop down box.

UITypeEditor gives you more control and more opportunity to implement custom behavior, but also requires more coding.

|||I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.|||

<BarefacedCheek>
Has anyone got the code that uses TypeConverter to provide a list of your connection managers in a combo box in the properties pane for a custom task? It'd save me an *awful* lot of work in working it out for myself if I could just nab someone else's!!

For example, in


GetStandardValues(...)

in my class that inherits from TypeConverter I need to get a list of connection managers in the task. How on earth do I do that?

Here's what I have already which is quite frankly nothing at all:


public class ConnectionManagerList : TypeConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}

public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
StandardValuesCollection connManList;

//What goes in here?

return connManList;
}
}


Thanks
Jamie
</BarefacedCheek>

|||

Use "context.Instance" to get your class for the property. From that you need to get the Connections collection, which depends on what the class is. Loop the connections and assign to the values collection. Job done. What your class is and how you expose the connections collection is the thinking bit.

|||I'm having some trouble with this. I have a breakpoint in the debugger, and when I view context.Instance, it is a Microsoft.DataTransformationServices.PipelineComponentMetadata class. I can't find any documentation on that class, and it doesn't seem to implement Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSComponentMetaData90, which is what I would have expected. What is context.Instance supposed to be?|||

The Instance will be whatever is parenting the grid. Looks like this is for a pipeline component, and that will differ from a task for example.

If you want a copy of IDTSComponentMetaData90, then PipelineComponentMetadata appears to have a property DtsComponentMetadata of type IDTSComponentMetaData90.

|||When I try to use the PipelineComponentMetadata object, it is giving me a compiler error, saying that the class is inaccessible :(|||

To get list of all connections managers, use IDtsConnectionService service. It is a public interface in Microsoft.SqlServer.Dts.Design and is documented in Books Online. It can be obtained from appropriate service provider.

PipelineComponentMetadata class is internal implementation details of the designer, don't use it.

|||Thanks Michael. Is there any way to get the output, input, and metadata collections? What I really need for the component I am working on is a list of the External Metadata columns for the first (only) input collection.|||

Where does your code live?

If this is UI Type Editor, you get ITypeDescriptorContext which gives you PropertyDescriptor. You can get the property value from it.

|||

Adam Tybor wrote:

I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.

Returning to this after a few months away...

Good stuff Adam. And that actually works really well for what I want to do.

However, I don't like the displaying of the ID rather than the name so I might decide to go down the UITypeEditor route instead.

-Thanks

Jamie

|||

Adam Tybor wrote:

I don't know about dataflow components, but on a custom task I simply created a property of type ConnectionManager and it gave me a drop down list of all the connectionmanager's guid's in the package. The built in type converter has a nice drill down connection manager editor too so you can easily identify which connection you selected. Its worth a shot for almost no programming at all.

Returning to this after a few months away...

Good stuff Adam. And that actually works really well for what I want to do.

However, I don't like the displaying of the ID rather than the name so I might decide to go down the UITypeEditor route instead.

-Thanks

Jamie

|||I am trying to do exactly the same, can someone point me in the right direction?

Another thing is how i add descriptions to properties in the class so it will appear in the propertygrid... and also how do i separate properties by specific nodes?

Regards

mail: djpirra@.gmail.com