Showing posts with label greatly. Show all posts
Showing posts with label greatly. Show all posts

Thursday, March 22, 2012

Custom Task and Reading Package Configuration

Hello All,

I have searched on this forum for a similar question but couldn't find it so I apologize if this has been asked. If so, I'd greatly appreciate a link to the question. I have created a custom task and am trying to read an xml package configuration file within my custom task. To be more specific, I have added an ADO.Net Connection to my database onto the package and have generated the appropriate tags within my package's configuration xml file. I'm not seeing the classes I should use to access the configuration file of the package I've created. Does anybody have any ideas how I can accomplish this or a link to a document that might cover the material? Thanks!

Jay_G

Jay,

First, let's be sure that what you're trying to do is what you really want to do.

Why do you want to read the configuration? Are you trying to do something with the configuration or do you simply want your custom task to be configured?

|||

Hello Kirk,

Thank you for responding. My custom task will, at times, need to read from a database and I figured the standard database connection string parameters would all be within the configuration file. I initially thought that I would need to use a package connection but the original intent of this custom task is be as easy to use and seemless as possible (meaning drop the task on the designer, set a few properties and be done). The custom task will be used over and over again within many packages. We didn't want to make all of our package developers have to configure a connection for this task but maybe this approach doesn't make sense. Does that make sense or should I be doing it a different way? I'm very new to SSIS and very much open to suggestions. Let me know if you need more clarification. Thanks again.

Jay_G

Monday, March 19, 2012

Custom Reports using Reporting Services

I have a couple of quetsions regarding the Reporting Services. Any response
will be greatly appreciated.
I am looking to see if the user has the capability to design thier own
reports using the reporting services..
Is it possible to provide the report design capability to the user so that
they can build custom reports using SQL Server Reporting Services ?
If yes, how can that be achived? If no, is there any third party tool that
can provide this capability to the user.
Thanks in advance,
--
snbatHi snbat:
Currently an end user needs Visual Studio installed to design reports.
Even the most basic (cheapest) version of the 2003 IDE can be used to
design reports.
There are also a slew of 3rd parties providing solutions, including
report designers (look at Cizer and SoftArtisans):
http://www.microsoft.com/sql/reporting/partners/softwareapps.asp
--
Scott
http://www.OdeToCode.com/
On Wed, 6 Oct 2004 08:05:03 -0700, "snbat"
<snbat@.discussions.microsoft.com> wrote:
>I have a couple of quetsions regarding the Reporting Services. Any response
>will be greatly appreciated.
>I am looking to see if the user has the capability to design thier own
>reports using the reporting services..
>Is it possible to provide the report design capability to the user so that
>they can build custom reports using SQL Server Reporting Services ?
>If yes, how can that be achived? If no, is there any third party tool that
>can provide this capability to the user.
>Thanks in advance,|||The next version of RS will include ad-hoc reporting functionality.
Currently, you can create your own ad-hoc report generator (it is not that
difficult) or use third-party tools as Scott mentioned.
--
Hope this helps.
----
Teo Lachev, MVP [SQL Server], MCSD, MCT
Author: "Microsoft Reporting Services in Action"
Publisher website: http://www.manning.com/lachev
Buy it from Amazon.com: http://shrinkster.com/eq
Home page and blog: http://www.prologika.com/
----
"snbat" <snbat@.discussions.microsoft.com> wrote in message
news:6C9CAFF3-E415-4E7A-8B25-246C5F64B762@.microsoft.com...
> I have a couple of quetsions regarding the Reporting Services. Any
response
> will be greatly appreciated.
> I am looking to see if the user has the capability to design thier own
> reports using the reporting services..
> Is it possible to provide the report design capability to the user so that
> they can build custom reports using SQL Server Reporting Services ?
> If yes, how can that be achived? If no, is there any third party tool that
> can provide this capability to the user.
> Thanks in advance,
>
> --
> snbat

Thursday, March 8, 2012

custom log provider type not recognized as a valid log provider

I am new to SSIS but I am learning fast. Any help is greatly appreciated.

I have written a custom log provider derived from LogProviderBase. I want to programmtically add the custom log provider to my package, but when I try this:

myPackage.LogProviders.Add("ACustomLogProvider");

I get the following exception:

"The log provider type "ACustomLogProvider" specified for log provider "{..GUID..}" is not recognized as a valid log provider type. This error occurs when an attempt is made to create a log provider for unknown log provider type. Verify the spelling in the log provider type name".

I have followed the instructions in BOL and as suggested in this forum, adding the DtsLogProvider attribute:

[DtsLogProvider(DisplayName="ACustomLogProvider", LogProviderType="ACustomLogProvider", Description="a description")]

Another way I tried is that I added a GUID attribute to my custom log provider class and then tried this:

Type aType = typeof(ACustomLogProvider);

Guid aGUID = (Guid)aType.GUID;

myPackage.LogProviders.Add("{"+ aGUID.ToString() +"}");

This also gives me the same exception "The log provider type ""{..the actual GUID for ACustomLogProvider..}" specified for log provider "{..a different GUID..}" is not recognized as a valid log provider type....

My questions are: Is it possible to add a custom log provider programmtically or must it be done through the SSIS Designer?

Must I deploy my custom log provider class for it to work programmatically? (I had perhaps wrongly assumed I would not have to deploy if I don't want it to show up in the SSIS Designer).

I would prefer to use a custom log provider instead of just logging within the SSIS event handlers because I can override the OnPostExecute, etc. but I cannot (can I?) override the specific event handlers like PackageStart, PackageEnd, etc because they are not exposed through DTSEvents.

Any help I would be very grateful for. Thanks.

I think you need to pass fully qualified type name to Add method:

myPackage.LogProviders.Add(aType.AssemblyQualifiedName);

|||

Thank you very much, Michael. That is working great.

I appreciate your help, especially since this seems like it was a trivial question. I should have been able to see that!

Thanks,

Amy

|||

Hi,

I've trying to create a custom log provider following msdn directions from:

http://technet.microsoft.com/en-us/library/ms365184.aspx

However, the example shown there for HtmlLogProvider does not work for me. I created the dll put it in every single folder it is indicated and also used gacutil and nothing. When I go to the SQL Server Business Intelligence Development Studio and I select "Logging" from the control flow, the only available log proivders that I see are the ones that came by default with the the IDE but not the one I created (HtmlLogProvider). I would like to know if you tried it and also had the same problem and if you could give me some advice of what to do.

Thanks so much

|||Try restarting the SSIS service.|||

I finally made it work for the HtmlLog Provider but sometimes it works and sometimes it does not. By some reason sometimes it does fill data inside the html and sometimes it does nothing with it. I have wondering what may be the reason.

The steps I followed once I had the Log Provider installed in the GAC and copied into the log provider folder was to do:

Logging

Add Custom log provider

and choose the package level and som of the events (On error, etc). I also tried selecting everything.

I also tried clickng on "Log Events" but what it does is only show a window with the logged events.

Please tell me if there is a bug with the log providers in SSIS or if I am not following the right steps.

Thanks a lot

|||

I'm not aware of any bug with the log providers. The stock log providers work using the same extensibility mechanism as you should be using, so if stock log providers work OK, you need to debug why yours is not working.

It is unclear what do you mean by "sometime it does nothing with it" - have you debugged whether the log provider receives the events you expect it to receive?

|||

I am sorry I was not too specific with what I meant. Let me try to make myself more clear. First I downloaded an example of an HtmlLogProvider from MS and tried it and worked. Now I was looking at the methods that are overwritten and I wanted to create my own log provider. So I tried to do it as simple as possible. So in my dummy example I just wanted to see the errors of my dtsx pacakge thru my cutom log provider. The code is as follows:

namespace HtmlLogProviderCS

{

using System;

using Microsoft.SqlServer.Dts.Runtime;

using System.IO;

using System.Web.UI;

using System.Web;

// The LogProviderType property is required but not used.

// The custom log provider will not appear in the list

// if a LogProviderType is not provided.

[DtsLogProvider(DisplayName = "MyLogProviderTest", Description = "A simple log provider.", LogProviderType = "Custom")]

public class HtmlLogProviderCS : LogProviderBase

{

#region Variables and constants

// Constants.

private const string SUBCOMPONENT = "HtmlLogProviderCS";

private const string PACKAGE_END_EVENT = "PackageEnd";

// Variables.

private Microsoft.SqlServer.Dts.Runtime.Connections _connections;

private Microsoft.SqlServer.Dts.Runtime.IDTSInfoEvents _events;

private string _configString;

private string _logFile;

private HtmlLogWriterCS _htmlLogWriter;

private MemoryStream _logStream;

private StreamWriter _logStreamWriter;

// Status flags.

private bool _fireEventsAgain=true;

private bool _loggingAlreadyStarted;

private bool _packageHasEnded;

#endregion

public override void InitializeLogProvider(Microsoft.SqlServer.Dts.Runtime.Connections connections, Microsoft.SqlServer.Dts.Runtime.IDTSInfoEvents events, Microsoft.SqlServer.Dts.Runtime.ObjectReferenceTracker refTracker)

{

_events = events;

System.Windows.Forms.MessageBox.Show("Init");

}

public override Microsoft.SqlServer.Dts.Runtime.DTSExecResult Validate(Microsoft.SqlServer.Dts.Runtime.IDTSInfoEvents events)

{

System.Windows.Forms.MessageBox.Show("Validate");

return DTSExecResult.Success;

}

public override void OpenLog()

{

System.Windows.Forms.MessageBox.Show("OpenLog");

}

public override void CloseLog()

{

System.Windows.Forms.MessageBox.Show("CloseLog");

}

public override void Log(string logEntryName, string computerName, string operatorName, string sourceName, string sourceID, string executionID, string messageText, DateTime startTime, DateTime endTime, int dataCode, byte[] dataBytes)

{

System.Windows.Forms.MessageBox.Show("Logging...");

System.Windows.Forms.MessageBox.Show("Message is: " + logEntryName + "--" + computerName + "--" + operatorName + "--" + sourceName + "--" + sourceID + "--" + executionID + "--" + messageText);

}

}

}

Many of the variables declared in there are just there cuz they were in the example I took form the HtmlLogProvider but other than that there's no reason for them to be there. So I really do not know why this Log is not working. The weird thing is that the message that am putting for every method does pop op correctly in every method EXCEPT for the LOG method which is not even invoked.

Tuesday, February 14, 2012

cursors question

I'll greatly appreciate any help with the error message bellow. What I am
trying to do is first I am getting a customer type and nr of members of that
type. Next I list first 5 customers and if there are more than 5 I want a
message to appear indicating how many more records are remaining and the las
t
record. Here is what I get:
3 J, Total nr. of records 5
1 R, M
2 H, S
3 S, S
4 W, G
5 W, P
4 O, Total nr. of records 1
1 V, D
5 R, Total nr. of records 17
1 M, M
2 V, J
3 R, R
4 D, K
5 S, M
Server: Msg 16911, Level 16, State 1, Line 39
fetch: The fetch type last cannot be used with forward only cursors.
.. There are 12 more records
-->> The last record being S, S
My code looks something like this:
declare @.MemID varchar(10)
declare @.total int
declare @.RowNum int
declare @.NamesNum int
declare @.RowNum1 int
declare @.fname varchar(20)
declare @.lname varchar(20)
declare MemList cursor for
select benefit, count(*) total from cust where branch='xxx' group by benefit
OPEN MemList
FETCH NEXT FROM MemList
INTO @.MemID, @.total
set @.RowNum = 0
WHILE @.@.FETCH_STATUS = 0
BEGIN
set @.RowNum = @.RowNum + 1
print cast(@.RowNum as varchar) + ' ' + LEFT(@.MemID, 1) + ', Total nr. of
records ' + cast(@.total as varchar)
---
declare namesList cursor
FOR select surname, name from cust where branch='xxx' and benefit=@.MemID
OPEN namesList
FETCH NEXT FROM namesList
INTO @.lname, @.fname
set @.RowNum1 = 0
WHILE @.@.FETCH_STATUS = 0 AND @.RowNum1 < 5
BEGIN
set @.RowNum1 = @.RowNum1 + 1
print ' ' + cast(@.RowNum1 as varchar) + ' ' + LEFT(@.lname,1) + ', ' +
@.fname
FETCH NEXT FROM namesList
INTO @.lname, @.fname
END
IF @.total >= 6
WHILE @.@.FETCH_STATUS = 0
BEGIN
FETCH LAST FROM namesList
INTO @.lname, @.fname
PRINT ' ... There are ' + ' ' + cast((@.total - 5) as varchar) + ' more
records'
PRINT ' -->> The last record being ' + LEFT(@.lname, 1) + ', ' + @.fname
END
CLOSE namesList
DEALLOCATE namesList
---
FETCH NEXT FROM MemList
INTO @.MemID, @.total
END
CLOSE MemList
DEALLOCATE MemList
Thanks for your help!Hi,
In Order to Use the LAST function you have to declare the Cursor as a
Scroll Cursor.
Please see code below - take note in a slight modification to stop the
Cursor repeating itself.
HTH
Barry
SQL CODE:
declare @.MemID varchar(10)
declare @.total int
declare @.RowNum int
declare @.NamesNum int
declare @.RowNum1 int
declare @.fname varchar(20)
declare @.lname varchar(20)
declare MemList cursor for
select benefit, count(*) total from cust where branch='xxx' group by
benefit
OPEN MemList
FETCH NEXT FROM MemList
INTO @.MemID, @.total
set @.RowNum = 0
WHILE @.@.FETCH_STATUS = 0
BEGIN
set @.RowNum = @.RowNum + 1
print cast(@.RowNum as varchar) + ' ' + LEFT(@.MemID, 1) + ', Total
nr. of records ' + cast(@.total as varchar)
---
declare namesList scroll cursor -- Declare the Cursor as a Scroll
Cursor
FOR select surname, name from cust where branch='xxx' and
benefit=@.MemID
OPEN namesList
FETCH NEXT FROM namesList
INTO @.lname, @.fname
set @.RowNum1 = 0
WHILE @.@.FETCH_STATUS = 0 AND @.RowNum1 < 5
BEGIN
set @.RowNum1 = @.RowNum1 + 1
print ' ' + cast(@.RowNum1 as varchar) + ' ' + LEFT(@.lname,1) +
', ' +
@.fname
FETCH NEXT FROM namesList
INTO @.lname, @.fname
END
--IF @.total >= 6 -- Remove this from here...
WHILE @.@.FETCH_STATUS = 0 And @.Total >= 6 ... and put it here...
BEGIN
FETCH LAST FROM namesList
INTO @.lname, @.fname
PRINT ' ... There are ' + ' ' + cast((@.total - 5) as varchar) + ' more
records'
PRINT ' -->> The last record being ' + LEFT(@.lname, 1) + ', ' +
@.fname
Set @.total = 0 --Set The Total to Zero so this loop finishes
END
CLOSE namesList
DEALLOCATE namesList
---
FETCH NEXT FROM MemList
INTO @.MemID, @.total
END
CLOSE MemList
DEALLOCATE MemList|||Why use a cursor to do all that formatting rather than just output a
query? Have you looked up the CUBE / ROLLUP operator in Books Online?
It would help you with the total counts.
If you want help to write a query instead of a cursor then please post
DDL and sample data. Cursors are rarely a good idea and surely not for
this - there really are much better ways to write reports.
http://www.aspfaq.com/etiquette.asp?id=5006
David Portas
SQL Server MVP
--|||hehe!
I was going to maybe post an example to use rather than a cursor -- but
I haven't really got the time!
And without any DDL - I definitely don't have time... ;-)
Barry|||This could be close to what you want but it is untested. It should give
you the first 5 customers per benefit. I've no way of knowing what you
mean by "first" and "last" so I've assumed alphabetical order by name.
You didn't specify ORDER BY so the order you will get from your cursor
is undefined and may be unreliable.
SELECT C.benefit, C.surname, C.name, B.row_cnt, B.last_cust
FROM cust AS C,
(SELECT benefit, COUNT(*) AS row_cnt,
MAX(surname+','+name) AS last_cust
FROM cust
GROUP BY benefit) AS B
WHERE branch='xxx'
AND 5 <=
(SELECT COUNT(*)
FROM cust
WHERE surname+','+name <
C.surname+','+C.name)
AND B.benefit = C.benefit
ORDER BY C.benefit, C.surname, C.name ;
The pretty formatting you can do at the front end or in a reporting
tool.
Hope this helps.
David Portas
SQL Server MVP
--|||Correction. Change "<=" to ">="
David Portas
SQL Server MVP
--