Showing posts with label particular. Show all posts
Showing posts with label particular. Show all posts

Friday, March 30, 2012

Having trouble getting connections

I have a custom Data Flow Destination Adapter that is looking for a particular type of ConnectionManager. I want to check that this connection exists in the Validate method. I first checked the ComponentMetedata.RuntimeConnections, but it was was an empty collection. I am guessing that it gets populated at runtime. Is there anything available for to check at design time?

Another way of asking this would be, Is there a way to programatically select which ConnectionManager gets assigned to a RuntimeConnection? Normally, this is done on the Connections tab of the Advanced Editor.

Thanks,

Graham

You can assign a connection manager at design time to your adapter and check that it is the correct type in the Validate() method. You will need to let your component know that it is expecting a connection manager.


Allan

|||I realize that I can do that by opening the advanced editor on my destination task and selecting the connection; but I dont want to do it that way. I want to Programmatically look for a connection of a specific type. Below is a code snippet of what I tried to do, but that doesnt seem to work. The connection is not set.



//this takes place in the onload handler for my DestinationAdapter form
//connections is passed in from the UI class that implements IDtsComponentUI
ConnectionManager connMan = null;
foreach (ConnectionManager cm in connections)
{
if (cm.InnerObject.GetType() == typeof(ProfileConnectionManager))
{
connMan = cm;
}
}
profConnMan = ProfileConnectionManager.FindProfileConnection(connections);
dtsComponentMetaData.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(connMan);


|||Is there a reason you don't just get the value of ConnectionManagerType on the properties collection? Also, you're attempting to use a managed code idiom for a connection that may not be managed. Most of the connection managers are native. Is this a custom connection manager? I don't know about the ProfileConnectionManager.|||

You may also want to take a look at IDtsConnectionService.GetConnections and IDtsConnectionService.CreateConnection. Useful for writing UIs. They all work around the connection type that Kirk mentions.

|||ProfileConnectionManager is a custom connection that I have written. I want to allow a custom data flow destination adapter that I have written to look for a ProfileConnectionManager and if one is defined, add it to my CustomDestinationAdapter.ComponentMetaData.RuntimeConnections collection.

In normal situations, this is done at design time by openning the advanced editor and selecting the connection manager from a dropdown. In my situation, I am allowing only one ProfileConnectionManger to be created. So if it exists, I dont want the user to have to select it from the advanced editor; I want that to be done programmatically by me.

When you refer to properties collection, are you saying I should add a property to MyCustomDestinationAdapter.ComponentMetaData.CustomPropertyCollection and assign my custom connection as its value?

thanks,
Graham|||

I would use GetConnections, albeit in a UI, something like this-

foreach (ConnectionManager connectionManager in _dtsConnectionService.GetConnectionsOfType(connectionType))
{
comboBox.Items.Add(connectionManager.Name);
}

connectionType is the string that identifies the type of connection I want. For example if I want ADO.Net SQLClient connections I need to use-

"ADO.NET:System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

It is a bit annoying that I have to use the fully qualified name, but that's what works.

The ConnectionManager also has a CreationName property which I use often for validation, and Kirk suggests a ConnectionType property, so using this you could loop as you where above, and check such a property to see if it is your connection. What you should not do is try and get a .Net Type object for the connection manager, as not all of them are .Net objects.

sql

Monday, March 26, 2012

HAVING Clause has no effect

I have this stored procedure. I want to run a few simple SQL functions against my tables. In particular I want to take a subset of records (One or Two years worth) and calculate AVG, VAR and STDEV.

It does not work the way I thought it would. I end up with the whole input table in #tempor1 which is about 6 years worth of records.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER OFF

GO
ALTER PROCEDURE [dbo].[findAve1YearDailyClose_MSFT]
AS
BEGIN
SET NOCOUNT ON;
SELECT adjClosed, volume INTO #tempor1 FROM dbo.dailyCl_MSFT
GROUP BY dateTimed, adjClosed, volume
HAVING (dateTimed > DATEADD (year, -1, MAX (dateTimed)))

SELECT AVG (adjClosed) AS "AVGAdjClose1Year",
VAR (adjClosed) AS "VARAdjClose1Year", AVG (volume) AS "AVGVolume1Year",
STDEV (volume) AS "STDEVVolume1Year", COUNT (*) AS "total"
FROM #tempor1
END

Thus if I change the number of years I subtract from the latest date from 1 to 2 I end up with the same result. What is the problem?

Thanks.

What about using:

SELECT adjClosed, volume INTO #tempor1
FROM dbo.dailyCl_MSFT
WHERE dateTimed > (SELECT DATEADD(year, -1, MAX (dateTimed)) FROM dbo.dailyCl)
GROUP BY dateTimed, adjClosed, volume


HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

|||

Jens K. Suessmeyer wrote:

What about using:

SELECT adjClosed, volume INTO #tempor1
FROM dbo.dailyCl_MSFT
WHERE dateTimed > (SELECT DATEADD(year, -1, MAX (dateTimed)) FROM dbo.dailyCl)
GROUP BY dateTimed, adjClosed, volume

HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

It sure worked! Many thanks for a lesson. Marked as answered!

Thanks.

sql

Friday, March 9, 2012

Hardware for SQL Server

We are looking to install SQL Server and want to purchase
a new machine for it. Are there any particular machine
models that are known to work well with SQL Server (e.g.
HP Proliant or one of the Dells)? I know I can use just
about any machine since all the new ones meet the system
requirements but wanted to see if anybody out there has
any specific suggestions on models. Thanks!it would depend on your budget and business needs.
we use DL380 for SQL. RAID 1 for logs and RAID 5 for data.
btw, this is ME, not Me.
"Me" <anonymous@.discussions.microsoft.com> wrote in message
news:160b01c3df99$61d671e0$a401280a@.phx.gbl...
> We are looking to install SQL Server and want to purchase
> a new machine for it. Are there any particular machine
> models that are known to work well with SQL Server (e.g.
> HP Proliant or one of the Dells)? I know I can use just
> about any machine since all the new ones meet the system
> requirements but wanted to see if anybody out there has
> any specific suggestions on models. Thanks!|||Dell and Compaq / HP are both fine candidates but the model depends on what
you need to do.
--
Andrew J. Kelly
SQL Server MVP
"Me" <anonymous@.discussions.microsoft.com> wrote in message
news:160b01c3df99$61d671e0$a401280a@.phx.gbl...
> We are looking to install SQL Server and want to purchase
> a new machine for it. Are there any particular machine
> models that are known to work well with SQL Server (e.g.
> HP Proliant or one of the Dells)? I know I can use just
> about any machine since all the new ones meet the system
> requirements but wanted to see if anybody out there has
> any specific suggestions on models. Thanks!|||Thanks guys!

Hardware for SQL Server

We are looking to install SQL Server and want to purchase
a new machine for it. Are there any particular machine
models that are known to work well with SQL Server (e.g.
HP Proliant or one of the Dells)? I know I can use just
about any machine since all the new ones meet the system
requirements but wanted to see if anybody out there has
any specific suggestions on models. Thanks!it would depend on your budget and business needs.
we use DL380 for SQL. RAID 1 for logs and RAID 5 for data.
btw, this is ME, not Me.
"Me" <anonymous@.discussions.microsoft.com> wrote in message
news:160b01c3df99$61d671e0$a401280a@.phx.gbl...
quote:

> We are looking to install SQL Server and want to purchase
> a new machine for it. Are there any particular machine
> models that are known to work well with SQL Server (e.g.
> HP Proliant or one of the Dells)? I know I can use just
> about any machine since all the new ones meet the system
> requirements but wanted to see if anybody out there has
> any specific suggestions on models. Thanks!
|||Dell and Compaq / HP are both fine candidates but the model depends on what
you need to do.
Andrew J. Kelly
SQL Server MVP
"Me" <anonymous@.discussions.microsoft.com> wrote in message
news:160b01c3df99$61d671e0$a401280a@.phx.gbl...
quote:

> We are looking to install SQL Server and want to purchase
> a new machine for it. Are there any particular machine
> models that are known to work well with SQL Server (e.g.
> HP Proliant or one of the Dells)? I know I can use just
> about any machine since all the new ones meet the system
> requirements but wanted to see if anybody out there has
> any specific suggestions on models. Thanks!
|||Thanks guys!