[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Stored procedure print statment passed to C# web application

Posted on 2006-06-06
Medium Priority
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

dstanley9 earned 2000 total points
ID: 16845517
To get the PRINT statements, you need to handle the SqlConnection.InfoMessage event.  


Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

872 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