Stored procedure with result RRS feed

  • Question

  • I have a simple stored procedure that I am executing and just want to get the result of the stored procedure.  0 if successful otherwise the error code.  I read the article saying set the result in the inserting event but not sure what needs to be set.  Can someone help?  Below is a snippet of my code. 

     Using command = New SqlCommand(procedure, connection)

                        command.CommandType = CommandType.StoredProcedure


                            New SqlParameter("@DataDomainID", entity.DataDomainID))


                            New SqlParameter("@SourceTableID", entity.SourceTableID))



    • Edited by Russ356 Wednesday, March 23, 2016 1:14 PM
    Wednesday, March 23, 2016 1:14 PM


  • Hi Russ356,

    >> 0 if successful otherwise the error code

    Do you mean if the stored procedure successful, it will return 0, otherwise, it will return an error code?

    Please refer to below articles which introduce how to execute a Stored Procedure in the inserting event. Hope that can help you. You can try the sample in that article first and then replace your stored procedure. If any questions, please feel free to come back.


    The connect string name you can find it in Web.config under the connectStrings node.

        <add name="_IntrinsicData" connectionString="Data Source=|SqlExpressInstanceName|;AttachDbFilename=|ApplicationDatabasePath|;Integrated Security=True;Connect Timeout=30;MultipleActiveResultSets=True" />
        <add name="7dd2326c-36f4-424c-962d-84fc0f9ca1ee" connectionString="Service Url=http://localhost:29935/Microsoft.LightSwitch.SecurityData.svc;Is Windows Authentication=False;User Name=Administrator;Password=username;Allow Invalid Certificate=False" />

    Best Regards,

    • Proposed as answer by Angie Xu Tuesday, April 5, 2016 8:16 AM
    • Marked as answer by Angie Xu Tuesday, April 5, 2016 8:16 AM
    Monday, March 28, 2016 8:13 AM