Lightswitch CBA Problem excecuting stored procedure RRS feed

  • Question

  • I have the following code on an inserting method in a CBA.

    partial void CapitalAllowanceAllocations_Inserting(CapitalAllowanceAllocations entity)
                int assetRegisterID = 1355313;
                int capitalAllowanceCategoryID = 1;
                decimal percentage = 0.50m;
                //int assetRegisterID = entity.AssetRegister.AssetRegisterID;
                //int capitalAllowanceCategoryID = entity.CapitalAllowanceCategories.CapitalAllowanceCategoryID;
                //decimal percentage = entity.Percentage;
                using (SqlConnection connection = new SqlConnection())
                    string connectionStringName = this.DataWorkspace.WahacaData.Details.Name;
                    connection.ConnectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
                    string procedure = "finance.CalculateCapitalAllowanceTotals";
                    using (SqlCommand command = new SqlCommand(procedure, connection))
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add(new SqlParameter("@AssetRegisterID", assetRegisterID));
                        command.Parameters.Add(new SqlParameter("@CapitalAllowanceCategoryID", capitalAllowanceCategoryID));
                        command.Parameters.Add(new SqlParameter("@Percentage", percentage));
                        command.CommandTimeout = 3000;

    The stored procedure should create rows in another table (CapitalAllowanceTotals) . The problem is the line  ' command.ExecuteNonQuery();

    'runs without a problem, however the rows are not created in 'CapitalAllowanceTotals' . When I execute the stored procedure in SSMS using the same credentials 87 rows are created in  'CapitalAllowanceTotals'.

    exec finance.CalculateCapitalAllowanceTotals 1355313,1,0.5

    Does anybody have any pointers as to where I may be going wrong?

    I have used this method of executing a stored procedure successfully in the same project.



    A Fleet

    Thursday, October 8, 2015 8:17 AM


  • Sorry this does work. Just bad testing.

    A Fleet

    • Marked as answer by A Fleet Sunday, October 11, 2015 12:21 PM
    Sunday, October 11, 2015 12:21 PM