Link to home
Start Free TrialLog in
Avatar of rketterer
rketterer

asked on

Stored procedure print statment passed to C# web application

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]

AS

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

PRINT 'This is broke'
      
ELSE
      BEGIN
      INSERT INTO tbl_ArchiveBillingST (Inst, NameOnDigitalDisplay, SetType,
      Bldg, Room, Jack, COR, COS, CoveragePath1, Extn, Account, AccountSupervisor, Dept, SetTypeCost,
      BillDates)
      SELECT Inst, NameOnDigitalDisplay, SetType,
      Bldg, Room, Jack, COR, COS, CoveragePath1, Extn, Account, AccountSupervisor, Dept, SetTypeCost,
      BillDates
      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;";
        objConn.Open();
        System.Data.SqlClient.SqlCommand objCmd = new System.Data.SqlClient.SqlCommand("sp_PopSTArchive", objConn);
        objCmd.CommandType = System.Data.CommandType.StoredProcedure;
        objCmd.ExecuteNonQuery();
        objConn.Close();
ASKER CERTIFIED SOLUTION
Avatar of dstanley9
dstanley9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial