简体   繁体   English

从LightSwitch HTML应用程序执行存储过程

[英]Execute Stored Procedure from LightSwitch HTML Application

I am new to LightSwitch and as such am unfamiliar with my toolset of entities and methods . 我是LightSwitch的新手,因此对我的实体和方法工具集不熟悉。

I have an application which uses a dataSource called BrattlecubesData and contains two views: TBG_V_TimeLog_Details and TBG_V_TimeLog_Projects . 我有一个使用名为BrattlecubesData的数据BrattlecubesData的应用程序,其中包含两个视图: TBG_V_TimeLog_DetailsTBG_V_TimeLog_Projects These two datasets are joined by ProjectID and used to display two different browse screens. 这两个数据集通过ProjectID连接在一起,并用于显示两个不同的浏览屏幕。

My problem is, I want to implement a button on a ViewDetails screen, which deletes the currently selected record from a dimension table (a dimension table which is not included in my application). 我的问题是,我想在ViewDetails屏幕上实现一个按钮,该按钮将从维表(我的应用程序中未包含的维表)中删除当前选择的记录。 I want to achieve this via StoredProcedure. 我想通过StoredProcedure实现这一点。

I have found an MSDN article detailing how to do this, but they focused on C# and VB rather than the Javascript which I am using in my HTML application. 我找到了一篇MSDN文章,其中详细介绍了如何执行此操作,但是它们专注于C#和VB,而不是我在HTML应用程序中使用的Javascript。

THIS LINK offers a translation of the MSDN C# code into Javascript, however I have been getting a recurring error in regards to my declaration of my dataset (error 0x800a138f - JavaScript runtime error: Unable to get property 'ApplicationData' of undefined or null reference ) 此链接提供了MSDN C#代码到Javascript的翻译,但是关于我对数据集的声明,我经常遇到错误(错误0x800a138f - JavaScript runtime error: Unable to get property 'ApplicationData' of undefined or null reference

I then decided to try the alternate technique of creating a table with which to execute my procedure, as outlined in the MSDN article above and also here . 然后,我决定尝试使用另一种创建表的方法来执行我的过程,如上面的MSDN文章以及此处所述 This technique however also eventually needed a button which led me to the Javascript, where I attempted to use the translated code resulting in the same error. 但是,该技术最终还需要一个按钮,该按钮将我引导至Javascript,在该脚本中,我尝试使用翻译后的代码,导致同样的错误。

Following the instructions from the MSDN blog by Eric Erhardt link, I have error free C# code to call my procedure but am stuck again on the Button which passes the LineItemID to my table and then procedure to be deleted. 按照Eric Erhardt链接从MSDN博客获得的说明,我可以使用无错误的C#代码来调用我的过程,但是又被卡在Button上,该按钮将LineItemID传递给我的表,然后删除过程。 My Button's Edit Execute Code code is below 我的按钮的“ Edit Execute Code代码如下

myapp.ViewRecordDetails.DeleteRecord_execute = function (screen) {

    var dws = screen.TBG_V_TimeLog_Detail.dataWorkspace;
    var comment = screen.TBG_V_TimeLog_Detail.selectedItem;

    var operation =
        dws.ApplicationData.DeleteProjectComment_Operations.addNew();
    operation.LineItemID = comment.LineItemID;

    dws.ApplicationData.saveChanges();
};

When run this is giving me the same 0x800a138f error an balking at 'ApplicationData'. 运行时,这给了我同样的0x800a138f错误,使我0x800a138f使用'ApplicationData'。 My solution does have a dataSource called ApplicationData which has a manually created table called DeleteProjectComment_Operations . 我的解决方案确实具有一个名为ApplicationData的数据源,该数据源具有一个手动创建的表,该表名为DeleteProjectComment_Operations Again, this button is located on a ViewDetails screen. 同样,此按钮位于ViewDetails屏幕上。 The ViewDetails has a button which links to an EditDetails screen, and the Editing works as I want. ViewDetails有一个链接到EditDetails屏幕的按钮,编辑工作如我所愿。

If I would be better off moving the Delete to my EditDetails screen, I am happy to do that. 如果最好还是将Delete(删除)移到EditDetails屏幕上,那么我很乐意这样做。 Or if the solution is to add the dimension table to my solution, please provide guidance on how to restructure my functions or screens 或者,如果解决方案是将尺寸表添加到我的解决方案中,请提供有关如何重组我的功能或屏幕的指南

I am at a loss for how to troubleshoot which entity I need to access or how to edit my code in order to pass the LineItemID to my procedure. 我不知道如何解决需要访问的实体或如何编辑代码以将LineItemID传递给过程的问题。

It has also been suggested to me that I could use AJAX to achieve my goal, and if that is the suggested route please provide me with some clarification on how that would be done. 还建议我可以使用AJAX来实现我的目标,如果这是建议的途径,请向我提供一些说明。

Thank you in advance, and I hope I have given enough detail, but am happy to provide more. 预先谢谢您,希望我能提供足够的细节,但很高兴提供更多信息。

It should be possible to successfully implement the Eric Erhardt approach by using the following execute code: 通过使用以下执行代码,应该有可能成功实现Eric Erhardt方法

myapp.ViewRecordDetails.DeleteRecord_execute = function (screen) {

    var dws = myapp.activeDataWorkspace;
    var comment = screen.TBG_V_TimeLog_Detail;

    var operation = dws.ApplicationData.DeleteProjectComment_Operations.addNew();
    operation.LineItemID = comment.LineItemID;

    dws.ApplicationData.saveChanges();
};

The only difference from your code is a change to the dws assignment from: 与您的代码的唯一区别是对dws分配的更改是:

var dws = screen.TBG_V_TimeLog_Detail.dataWorkspace;

to: 至:

var dws = myapp.activeDataWorkspace;

If you're still encountering problems after this modification, I would extend the saveChanges call to report any errors as follows: 如果您在此修改后仍然遇到问题,我将扩展saveChanges调用以报告任何错误,如下所示:

dws.ApplicationData.saveChanges().then(null, function (errors) {
    errors.forEach(function (error) { 
        alert(error.message); 
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有Button_execute事件的LightSwitch HTML更改格式格式 - LightSwitch HTML change format format with Button_execute event 异步执行LightSwitch Javascript - Execute LightSwitch Javascript Asynchronously 使用存储过程执行时executeUpdate()不起作用 - executeUpdate() is no working while execute using stored procedure 在 NestJS 中执行 Oracle 数据库存储过程 - Execute an Oracle DB stored procedure In NestJS 如何通过JS代码或存储过程在DocumentDB中执行预触发 - How to execute a pre-trigger in DocumentDB from a JS code or Stored Procedure HTML LightSwitch的计算属性 - Computed property with HTML LightSwitch Lightswitch HTML客户端:如何重新呈现项目(重新执行postRender回调) - Lightswitch HTML Client: How to re-render an item (re-execute postRender callback) node-mssql将不会执行提供unhandlePromiseRejectionWarning的存储过程 - node-mssql won't execute stored procedure giving unhandlePromiseRejectionWarning 雪花存储过程为外部表执行创建语句 - Snowflake Stored Procedure to execute create statement for external table 如何在JavaScript上执行存储过程Confirmbutton在ASP.NET中单击 - How to Execute the Stored Procedure on Javascript Confirmbutton Click in ASP.NET
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM