Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Create a status bar inside SSIS C# Script?

$
0
0

I am moving rows from one table to another using a C# script. Please don't tell me to use SSIS components for that. I am looping the incoming dataset using a for loop and I want to see the current iteration, ie for loop index in a GUI box. I can useMessageBox.Show("Text"), but I need to press ok/cancel to allow the code to continue. So, I thought of using a status bar instead. I tried an example I got online - http://www.c-sharpcorner.com/uploadfile/mahesh/statusbar-in-C-Sharp/

The line this.Controls.Add(mainStatusBar); in the example (below) causes the error -

csproj.ScriptMain' does not contain a definition for 'Controls'
and no extension method 'Controls' accepting a first argument of type '.csproj.ScriptMain' could be found (are you missing a using directive 
or an assembly reference?)

This happens despite adding the reference - System.Windows.Forms.dll and doing a save all (ieCtrl+Shift+S). The script has a import using System.Windows.Forms; already.

Why am I getting this error and how do I fix it ?

Code -

protectedStatusBar mainStatusBar =newStatusBar();protectedStatusBarPanel statusPanel =newStatusBarPanel();protectedStatusBarPanel datetimePanel =newStatusBarPanel();privatevoidCreateStatusBar(){// Set first panel properties and add to StatusBar
    statusPanel.BorderStyle=StatusBarPanelBorderStyle.Sunken;
    statusPanel.Text="Application started. No action yet.";
    statusPanel.ToolTipText="Last Activity";
    statusPanel.AutoSize=StatusBarPanelAutoSize.Spring;
    mainStatusBar.Panels.Add(statusPanel);// Set second panel properties and add to StatusBar
    datetimePanel.BorderStyle=StatusBarPanelBorderStyle.Raised;
    datetimePanel.ToolTipText="DateTime: "+System.DateTime.Today.ToString();
    datetimePanel.Text=System.DateTime.Today.ToLongDateString();
    datetimePanel.AutoSize=StatusBarPanelAutoSize.Contents;
    mainStatusBar.Panels.Add(datetimePanel);

    mainStatusBar.ShowPanels=true;// Add StatusBar to Form controlsthis.Controls.Add(mainStatusBar);}privatevoid button1_Click(object sender,EventArgs e){
    statusPanel.Text="Button is clicked.";}privatevoid checkBox1_CheckedChanged(object sender,EventArgs e){
    statusPanel.Text="CheckBox is checked.";}privatevoid textBox1_TextChanged(object sender,EventArgs e){
    statusPanel.Text="TextBox edited.";}

Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>