SSIS Logging - Capture Variables? - sql-server

I'm trying to capture the values of about 15 variables within my sysssislog when my package executes.
I have set all the variables to true for "Raise event when variable value changes" and I understand I have to put some sort of object/code into the Event handler but I'm totally unsure as to what this should look like for the 15 variables.
Can anyone offer some examples please?

After the RaiseChangedEvent property is set to true on the variable the OnVariableValueChanged event will need be selected for logging to SYSSSISLOG. This can be done by right-clicking the package and selecting Logging then going to the Details tab and checking the check-box for the OnVariableValueChanged event. After this click the Advanced button and check the box for each element that will be logged, for instance Computer, SourceName, etc. To see the actual value that the variable was changed to query the SSISDB.CATALOG.EVENT_MESSAGES DMV following package execution. The MESSAGE column will show the value that the variable was set as during package execution.

Related

How can I populate a combobox from a SQL Server database server in Delphi?

First of all, I'm new to Delphi, and I checked all the relevant threads on here, but nothing seems to be working.
I'm just trying to fill a TComboBox with values of a column from a SQL Server database.
So basically, I have a VCL form and a DataModule, which holds an ADOConnection and an ADOQuery. The ADOConnection connects to my database (test connection says it's successful) and the ADOQuery connects to my ADOConnection. The VCL form and the DataModules are "connected".
(And actually here comes another problem: whenever I'm trying to enter SELECT name FROM Partners; in the properties of my ADOQuery and try to set it active, it keeps saying "Invalid object name 'Partners'". The SQL statement is correct, I tested it in SSMS and it retrieves the data without any error. But I'm not sure if it's the main issue here).
So basically, here's my code:
procedure TFormInsertNewItem.ComboBoxPartnersDropDown(Sender: TObject);
begin
with DataModule1 do
begin
ComboBoxPartners.Items.Clear;
ADOQueryFillPartners.SQL.Clear;
ADOQueryFillPartners.SQL.Add('SELECT name FROM Partners;');
ADOQueryFillPartners.Active:=true;
ADOQueryFillPartners.Open;
while not ADOQueryFillPartners.Eof do begin
ComboBoxPartners.Items.Add(ADOQueryFillPartners.FieldByName('name').AsString);
ADOQueryFillPartners.Next;
end;
ADOQueryFillPartners.Active:=false;
ADOQueryFillPartners.Free;
end;
end;
Whenever I click to drop it down (or maybe it would be better if this runs when the form is loaded, but I have no idea how can I exactly refer to that event), it should fill it up. Well, it won't. I tried it with TDBComboBox and TDBLookUpComboBox, with setting their datasource, but it only added 1 item to the combobox.
Can anyone help me with what I messed up and how can I get it to work, please?
You have multiple problems in the code you've posted.
Clearly, the first thing you have to do is to get your query to open properly. If you can't run the query to get the data, you can't use that data to populate the combobox. Test your ADOConnection on your datamodule to see if you can connect to the database by setting its Connected property to True.
If that doesn't work, then you need to set up your ConnectionString properly. (Make sure you set the Connected property back to False. You should be connecting in your datamodule's OnCreate event, and disconnecting in the datamodule's OnDestroy event.)
If it does work, check to make sure you set the ADOQuery's Connection property to point to your ADOConnection, and then use the ADOQuery.SQL property to enter your SQL statement. Once you've done that, set the ADOQuery.Active property to True. (Again, don't forget to set it back to False and open it in your code at runtime.)
Next, you've used the wrong event. You should be doing this in the form's OnCreate event instead.
Also, you don't need both Active and Open for the query. They do the same thing; the only difference between them is that Active is a Boolean property that can be tested (if Query1.Active then) while Open is simply a method. There's no reason to open a query that's already active or make a query active that's already open.
In addition, you free the query at the end of your method, which means that the next time the combobox OnDropDown event is called, you're accessing an invalid class instance, which will cause an access violation.
And finally, you should be calling BeginUpdate before clearing and populating the combobox, and then EndUpdate when you're finished.
A more correct version of the code would be something like
procedure TFormInsertNewItem.FormCreate(Sender: TObject);
begin
with DataModule1 do
begin
{
I'm not sure why you're doing this at all. If you set the ADOQuery.SQL property
at designtime, and it never changes, you can remove the next two lines.
}
ADOQueryFillPartners.SQL.Clear;
ADOQueryFillPartners.SQL.Add('SELECT name FROM Partners;');
ADOQueryFillPartners.Active:=true;
try
ComboBoxPartners.Items.BeginUpdate;
while not ADOQueryFillPartners.Eof do begin
ComboBoxPartners.Items.Add(ADOQueryFillPartners.FieldByName('name').AsString);
ADOQueryFillPartners.Next;
end;
finally
ComboBoxPartners.Items.EndUpdate;
end;
ADOQueryFillPartners.Active:=false;
end;
end;

How do you use the SQLQuery component to run multiple queries?

I have a ListBox showing all the records for a single field (first) in a database. When users click the ListBox item I'd like the value for a different field in the db (last), same record, to be displayed. My code ListBox OnClick event code is:
SQLQuery2.SQL.Text:='SELECT * FROM Names WHERE first= :FIRST';
SQLQuery2.Params.ParamByName('FIRST').AsString := ListBox1.Items[ListBox1.ItemIndex];
SQLQuery2.Open;
ShowMessage('You selected '+SQLQuery2.FieldByName('last').AsString);
When you click an item, the expected field comes up in the MessageBox. However, if you then click a different item, nothing changes--the MessageBox shows the original field.
I don't know enough about SQLQuery components and how they interact with the underlying db to know what's happening.
[P.S. The db is sqlite3, if that matters, and I'm using Lazarus rather than Delphi, if that matters.]
You need to close your query before opening it again. If you look at the code for Open on TDataSet it sets the Active property to true. The setting code for Active first checks that the value is different before doing any work:
procedure TDataSet.SetActive(Value: Boolean);
begin
..
if Active <> Value then
begin
end;
end;
So in your case, the active property is already true and the code just exits.

Where do I add a trigger for "Notes and Attachments" in salesforce.com?

I cannot find where in the salesforce.com UI I can add a trigger on a file attachment. I can find triggers on almost everything else, but attachment seems to be missing from the list (even when I view source on the page and search it. Does anyone know WHERE I can put this trigger in?
There is no way to do it directly as Attachment is one of those "lesser" objects that salesforce really gets "protective" about in a random and biased way. The only "legit" way to do it is to use some external build&deploy tools such as Force.com IDE.
If however you are not a stranger to undocumented 'hacks' do the following. Go to any object's trigger list and click create new. In the URL locate entity query string parameter (e.g. entity=Case) and change it to Attachment (entity=Attachment) and press Enter. Newl loaded screen will accept Attachment trigger.
Using Eclipse (Force.com IDE plug-in), right-click on your project & select "New" > "Apex Trigger". In the dialogue window that pops up, there is an "Object" dropdown / picklist, choose the object you want from this list - "Note" or "Attachment" etc. - then choose the "events" you want to trigger to execute on.
NOTE: a best practice is only one (1) trigger per object since you cannot guarantee the order in which multiple triggers on the same object will execute.
Have you tried creating the trigger from, force.com IDE??
In my opinion it should be possible from there.
To write a trigger for attachment, there is no straight way to do it but you can do it.
By creating a trigger on other object for example create a trigger in contact object then the url of the current page shows
"https://ap1.salesforce.com/........./&entity=Contact" you have to change "entity=Attachment"
then the trigger will be created for attachment object.

Customizing Mail Message in SSIS Event Handler

I want to add an email notification to an SSIS 2005 package event handler. I've added a Send Mail task to the event handler. I'd like to customize the email body to include things like the error description. I've tried including #[System::ErrorDescription] in the MessageSource field, but the mail message doesn't include the value of ErrorDescription only the name of the variable.
In the dialog for the Send Mail Task, select the word Mail in the list on the right. This brings up the property page for the Mail task. Set the MessageSourceType value to Variable and set the MessageSource to the name of the variable you want to use in the format System::ErrorDescription. This is how I used this component in SQL server 2005. I believe that the steps are similar in 2008, but it has been a while since I worked at a 2008 client, so I am working from memory there.
I think you are using MessageSource property in mail tab. You need to go to expressions then in the property select MessageSource and browse for expression button, there you can drag and drop #[System::ErrorDescription] variable into Expression text area.
Click on Evaluate expression it should not give any error message and you are done.
The name of the failed task is inthe system variable
System::SourceName

SQL server reporting services: how to stop a report firing when opened

We have some SQL server reporting services reports. I didn't write then but I have to take care of them.
These reports fire when opened in the browser, and with the default parameters (search terms and restrictions are blank) they retrieve a lot of data, which is slow. The client would prefer that the report is not generated until the user enters parameters and presses "view report"
Unfortunately I don't know SSRS at all well - how do I stop the report from firing when it is opened?
The details of how to do it on a deployed report (as per Rihan Meij's answer) is as follows:
Click on a report, click on "properties" at the top. You may have to wait a bit, because the slow report may be running now. Then click on "parameters" on the left.
For each parameter, make sure that "Prompt User" is checked, and for at least one parameter, "Has Default" is not checked. Click on "View" again at the top left (or go back to the folder and click on the report name) to view the report, and note that the report does not fire right away.
In the report builder, you can do this via the "Filter" menu. De-select values from at least one filter, and save the report.
Is it also possible to stop reports from firing on loading when the report has no parameters?
I found that I had to set at least one of the report parameters to not have a default to keep the report from autorunning.
I had to use this configuration (notice that all 3 of the parameters I left without defaults accept Nulls so the users can just click the Null checkboxes):
[screenshots missing]
to get the users to see this and to keep the report from autorunning:
[screenshots missing]
I set the default value of one of my parameter selections to a value of -1 which does not exist (not a valid parameter value). This did not generate an error. It simply set the parameter drop down box to and prevented the report from running. I couldn't use a default value of NULL because NULL selects everything, and I wanted the user to purposefully make the selection of ALL (NULL) before the report runs. It takes several minutes for the report to render if ALL is selected.
I know this post is a bit old, but since I have another solution here to, I just posting it in case someone need it.
If you are using ReportViewer its posible to set the property ShowBody="False". Then on the OnSubmittingParameterValues event, change the ShowBody property to true. Then you do not need any extra parameters or parameters without default value in the report.
<rsweb:ReportViewer
ID="rv"
runat="server"
Width="100%"
Height="100%"
SizeToReportContent="false"
ZoomMode="PageWidth"
KeepSessionAlive="true"
ProcessingMode="Remote"
PromptAreaCollapsed="false"
InteractivityPostBackMode="AlwaysAsynchronous"
AsyncRendering="true"
ExportContentDisposition="AlwaysInline"
ShowReportBody="False"
ShowPrintButton="false"
OnSubmittingParameterValues="rv_SubmittingParameterValues"/>
And then in the rv_SubmittingParameterValues method:
this.rv.ShowReportBody = true;
I have done that by changing my query slighlty to require parameters when it is run.
I have then after I have published the report on the report site, specified that the parameter, should prompt the user. This does have the effect that the report does not pull the sql server to its knees when users just open the report to see.
I found a nice trick for this when working with reports that have optional fields, but pull a huge amount of data if the optional fields are blank.
Step 1: Prevent Auto Firing
Make sure "Allow null value" is not enabled for the optional parameters
Make sure there is no default value for the optional parameters
Step 2: Make parameters optional without using 'null'
Enable "Allow blank value" for the optional parameters
Modify your where clause for the optional parameters to
WHERE (#param="" OR column = #param)
With this method there is are extra fields for the end users to worry about, the report will not fire until it is requested, and the conditions in the where clause will not be evaluated if the text box is left empty.
note: if the report specifies Available Values then any value that is not valid for your table structure may be used instead of "", you can also use with other data types (non-string) this way
I found the best way was to add in a parameter that does not allow nulls, but is not used by the report. This stops it from rendering at the start, but does not affect the report.
The only down side is if you are displaying the report in a report viewer you have a box at the top which looks a bit strange. I'm sure you could use some C#/CSS to hide it though.
As I'm not using a report viewer to display, only to render at the back end this doesn't affect me.
Even if you are using a report viewer it's helpful when developing!
I did this by just supplying a default value to the key parameter that doesn't return any results.
I added this in my query:
where 'Start' = #Start
and made a parameter with only available value 'Start'. The report is waiting for input.

Resources