Messagebox.show

I am new at this so be easy.

I have a messagebox.show that I want to display the result of a SQL select statement in. How do I do this please. I am using C# 2005.



Answer this question

Messagebox.show

  • Johan Petersson

    Hi,

    do you have an example in VB. I can't see to get this to work. Here is the code I am using. When invoked the page just sits there churning and eventualy comes back with page not found. Any idea what I'm missing

    Sub deleteComment(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs)

    Dim Message As String = "This is a test"

    Dim Caption As String = "Delete Comment"

    Dim Buttons As MessageBoxButtons = MessageBoxButtons.YesNo

    Dim Result As DialogResult

    Result = MessageBox.Show(Message, Caption, Buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification)

    End Sub


  • TerryG

    The DataSet.GetXML method returns a string that represents the data without schema. This isn't the most friendly format to display, but displaying a full DataSet in a MessageBox sounds bad for me.

    When you need it for debuggin, you can better flush it to you debug output window or something.


  • Sridhar Madhugiri

    After reading your post to my question it did make me think about what I was trying to do. So, I decided that rather than do a MessageBox I would do it in a form. That worked out perfect. Thanks for at least making thin outside the box. It was a real learning experience.

    One excited newbie,

    Harry


  • Norman

    Here is a little dirty piece of code, you must use a StringBuilder, finetune the code and format the message. But it is a example:


    DataSet result = ...;
    string message = string.Empty;

    foreach(DataTable table in result.Tables)
    {
        message += String.Format( "--- Table: {0} ---\r\n", table.TableName );

        foreach(DataRow row in table.Rows)
        {
            for(int i = 0; i < row.ItemArray.Length; i++)
            {
                message += String.Format("'{0}', ", row[ i ]);
            }

            message += Environment.NewLine;
        }

        message += Environment.NewLine;
        message += Environment.NewLine;
    }
    MessageBox.Show( message );

     



  • randy_w_s

    I believe it's time to learn how breakpoints, immediate windows, and watches are for. I believe the message box is so you can see the resultset, then work with it. If this is the case, I'd just utilize the debug mode, and break point specific areas. You can mouse over the variables and such, and see the values contained in them.


  • Greg Mandel

    DataSet result = ...;
    MessageBox
    .Show(result.GetXml());


  • Messagebox.show