943,694 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 950
  • ASP.NET RSS
Sep 8th, 2009
0

Smo.StoredProcedure Help!

Expand Post »
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;
        }
    }
Similar Threads
Reputation Points: 11
Solved Threads: 12
Junior Poster
Alexpap is offline Offline
117 posts
since Sep 2008
Sep 9th, 2009
1

Re: Smo.StoredProcedure Help!

Hi Alexpap ,

Post the complete error message. Becuase the error message that you posted is generic for SMO object.

Also Check the following things:

1. Database connection is estabilished before executing 'Create' method for StoredProcedure object by putting a break point.
2. sp.TextBody has correct syntax.
Reputation Points: 165
Solved Threads: 113
Posting Pro
Ramesh S is offline Offline
580 posts
since Jun 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Binding Data to text box
Next Thread in ASP.NET Forum Timeline: How can i serialize this object?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC