none
C# Script Task - MessageBox Variables

    Question

  • I dont know C#, so I thought I would start simple and try to do message box a variable. I am struggling even with that.

     

    In VB.net I would print a value of the variable in a message box using the following syntax.

     

                    Msgbox(dts.variables(“VariableName”).value.tostring)

     

    In C#

                    MessageBox.Show(Dts.Variables

     

    At the point of selecting variables it is giving me this message.

                    Error      1              Non-invocable member 'Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTAProxy.ScriptObjectModel.Variables' cannot be used like a method.         

     

    I have following using statements defined. Do I need more?

                    using System;

    using System.Data;

    using Microsoft.SqlServer.Dts.Runtime.VSTAProxy;

    using System.Windows.Forms;

    using Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTAProxy;


    I might be missing something. Can anyone help?

     

    Thanks

    Sutha

    Friday, July 11, 2008 10:59 AM

Answers

  • Indexing is done differently in C#.  To get the string representation of a variable called Foo, you would use:
    Dts.Variables["Foo"].Value.ToString()
    (notice the []s instead of ()s)

    Hence, to display a message box, you'd place that into the Show() call:
    MessageBox.Show(
    Dts.Variables["Foo"].Value.ToString())
    Friday, July 11, 2008 5:09 PM

All replies

  • Indexing is done differently in C#.  To get the string representation of a variable called Foo, you would use:
    Dts.Variables["Foo"].Value.ToString()
    (notice the []s instead of ()s)

    Hence, to display a message box, you'd place that into the Show() call:
    MessageBox.Show(
    Dts.Variables["Foo"].Value.ToString())
    Friday, July 11, 2008 5:09 PM
  • Brandon

     

    Thank you.

     

    Sutha

    Saturday, July 12, 2008 12:59 PM