Stored Procedure having errors within
=======================
CREATE PROCEDURE spError
AS
BEGIN
Begin Tran
Select 1/0
execute('insert into te mpPK select 1')
execute('insert into tempPK select 3')
Commit Tran
END
GO
=======================
Application Code
try
{
SqlConnection sCon = new SqlConnection();
sCon.ConnectionString = "Database=xyz;Server=11.62;User Id=sa;Password=klk";
sCon.Open();
SqlCommand sCom = new SqlCommand();
sCom.Connection = sCon;
sCom.CommandText = "Exec spError";
sCom.ExecuteNonQuery();
}
catch (Exception ex)
{
textBox1.Text = ex.Message;
}
=======================
Errors captured
Divide by zero error encountered.
Incorrect syntax near 'mpPK'.
No comments:
Post a Comment