Smo.StoredProcedure Help!

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 36
Reputation: Alexpap is an unknown quantity at this point 
Solved Threads: 0
Alexpap Alexpap is offline Offline
Light Poster

Smo.StoredProcedure Help!

 
0
  #1
Sep 8th, 2009
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;
        }
    }
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 433
Reputation: Ramesh S will become famous soon enough Ramesh S will become famous soon enough 
Solved Threads: 82
Ramesh S Ramesh S is offline Offline
Posting Pro in Training

Re: Smo.StoredProcedure Help!

 
0
  #2
Sep 9th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

Tags
c#, smoobjects

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC