Stored procedure print statment passed to C# web application

Posted on 2006-06-06
Last Modified: 2008-02-01
Hello Experts,
I was just trying to see if there is a way to do this.  It seems simple enough, but I can't find an answer.  
I am building a web app using C# and ASP.NET 2.0.  Below is a scaled down version of a SQL server 2005 stored procedure that I am using to populate some tables on a button_click.  All I was trying to accomplish was for the print statement to appear on the web interface (textbox, label etc.) so the user can see it.  I thought this seemed simple, but I couldn't get it to work, so I'm wondering if it can be done at all.  Thanks for any help!

ALTER PROCEDURE [dbo].[sp_PopSTArchive]


IF EXISTS (SELECT * FROM tbl_ArchiveBillingST WHERE BillDates = (SELECT BillDates
FROM vew_BillingSetType WHERE ID = '1' ))

PRINT 'This is broke'
      INSERT INTO tbl_ArchiveBillingST (Inst, NameOnDigitalDisplay, SetType,
      Bldg, Room, Jack, COR, COS, CoveragePath1, Extn, Account, AccountSupervisor, Dept, SetTypeCost,
      SELECT Inst, NameOnDigitalDisplay, SetType,
      Bldg, Room, Jack, COR, COS, CoveragePath1, Extn, Account, AccountSupervisor, Dept, SetTypeCost,
      FROM  vew_BillingSetType

C# Button Click Command

    protected void Button1_Click1(object sender, EventArgs e)
        //Activates the sp_PopSTArchive stored procedure in the PhoneBilling DB on button_click
        //Provides a link to view final bills just created
        System.Data.SqlClient.SqlConnection objConn = new System.Data.SqlClient.SqlConnection();
        objConn.ConnectionString = "Data Source=CCDADAPP01;Initial Catalog=PhoneBilling;Integrated Security=True;";
        System.Data.SqlClient.SqlCommand objCmd = new System.Data.SqlClient.SqlCommand("sp_PopSTArchive", objConn);
        objCmd.CommandType = System.Data.CommandType.StoredProcedure;
Question by:rketterer
    1 Comment
    LVL 25

    Accepted Solution

    To get the PRINT statements, you need to handle the SqlConnection.InfoMessage event.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video discusses moving either the default database or any database to a new volume.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now