Hello all,
I want to create a stored procedure using SMO Objects. I have set up all the properties of my Smo.StoredProcedure object, but when i try to create it, it throws me this Exception Message: Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch
Here's a little snippet of my code:
protected void btnCreateNewSP_Click(object sender, EventArgs e)
{
StoredProcedure sp = (StoredProcedure)Session["SP"];
sp.TextBody = txtSqlStatement.Text;
try
{
sp.Create();
lblErrorInfo.ForeColor = System.Drawing.Color.Green;
lblErrorInfo.Text = "Stored Procedure has been successfuly created!";
}
catch (Exception ex)
{
lblErrorInfo.ForeColor = System.Drawing.Color.Red;
lblErrorInfo.Text = ex.Message + " Error Info: " + ex.InnerException.Message;
}
}