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.SqlC onnection objConn = new System.Data.SqlClient.SqlC onnection( );
objConn.ConnectionString = "Data Source=CCDADAPP01;Initial Catalog=PhoneBilling;Integ rated Security=True;";
objConn.Open();
System.Data.SqlClient.SqlC ommand objCmd = new System.Data.SqlClient.SqlC ommand("sp _PopSTArch ive", objConn);
objCmd.CommandType = System.Data.CommandType.St oredProced ure;
objCmd.ExecuteNonQuery();
objConn.Close();
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.SqlC
objConn.ConnectionString = "Data Source=CCDADAPP01;Initial Catalog=PhoneBilling;Integ
objConn.Open();
System.Data.SqlClient.SqlC
objCmd.CommandType = System.Data.CommandType.St
objCmd.ExecuteNonQuery();
objConn.Close();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.