灯开关和存储过程

发布于 2024-12-10 12:28:47 字数 624 浏览 0 评论 0原文

我看过一些关于从 Lightswitch 中运行 SQL Server 存储过程的帖子,但我希望能够做的是:

  1. 创建一个 LightSwitch 应用程序(及其自己的数据库)
  2. 从 SQL Server Management Studio 连接到该数据库
  3. 创建一个或该数据库中的许多存储过程
  4. 可能安排这些存储过程每天运行

到目前为止,我已经在尝试附加到 Lightswitch ApplicationDatabase.mdf 的步骤 2 上挂断了。我收到以下错误,显然是因为没有关联的日志文件 (.ldf)。

我知道,将存储过程放置在 LightSwitch 生成的数据库中并欣赏这些输入可能不是最佳实践。

谢谢,

Keith

错误消息:“无法打开物理文件“C:\Documents and Settings\keithm\My Documents\Visual Studio 2010\Projects\Application13\Application13\Bin\Data\Temp\ApplicationDatabase_log.LDF”。操作系统错误2:“2(系统找不到指定的文件。)”(Microsoft SQL Server,错误:5120)”。

I've seen a few posts on running SQL Server stored procedures from within Lightswitch but what I would like to be able to do is:

  1. Create a LightSwitch application (along with its own database)
  2. Connect to that database from SQL Server Management Studio
  3. Create one or many stored procedures w/in that database
  4. Possibly schedule these stored procedures to run daily

So far, I have gotten hung up on step 2 where I'm trying to attach to the Lightswitch ApplicationDatabase.mdf. I get the error below, apparently because there is no associated log file (.ldf).

I understand that maybe it is not a best practice to be placing stored procedures in the LightSwitch generated database and appreciate input along these lines as well.

Thanks,

Keith

Error Message: "Unable to open the physical file "C:\Documents and Settings\keithm\My Documents\Visual Studio 2010\Projects\Application13\Application13\Bin\Data\Temp\ApplicationDatabase_log.LDF". Operating system error 2: "2(The system cannot find the file specified.)". (Microsoft SQL Server, Error: 5120)"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾城花音 2024-12-17 12:28:47

当我向 LightSwitch 生成的数据库添加新的增强功能时,我首先部署数据库,然后应用我设计的新功能(例如表、函数、存储过程)。只要我不修改LightSwitch生成的表,LightSwitch就不会受到影响,也不会干扰我在更新数据库时所做的修改。这个过程对我来说效果很好。

因此,我建议您部署应用程序,然后将存储过程添加到已部署的数据库中,而不是尝试访问 LS 开发 DB 数据文件。出于开发目的,您可以部署到测试环境并复制生成的数据库以供使用。

When I add new enhanced features to a LightSwitch generated database, I deploy the database first, then I apply the new features (e.g. tables, functions, stored procedures) that I've designed. As long as I don't modify the tables that LightSwitch has generated, LightSwitch will not be affected, nor will it interfere with the modifications I've made when it updates the database. This process has been working well for me.

So, rather than trying to access the LS development DB datafile, I would suggest that you deploy your application, then add your stored procedures to the deployed database. For development purposes, you can deploy to a test environment and make a copy of the resulting database to work against.

温柔女人霸气范 2024-12-17 12:28:47

为什么不在 Lightswitch 之外创建数据库?我认为直接访问内部 Lightswitch 数据库没有任何优势。事实上,这听起来是一个糟糕的主意。它并不意味着可以直接访问。

如果您在 Lightswitch 之外执行此操作,您可以在数据库设计中执行您想要的任何操作,包括所有表、存储过程等,没问题。最后将 Lightswitch 指向您的外部数据库,它将自动选择表和视图。 (不是存储过程)。

为了安排事情在设定的时间运行,请使用 SQLServer 中的 SQLAgent 作业(假设您正在使用 SQLServer)。这也是完全在 Lightswitch 之外完成的。

Lightswitch 的限制似乎促使我们远离存储过程;不要反对那个。将 Lightswitch 视为一个非常基本的创建/读取/更新/删除工具。将存储过程和计划作业作为 SQLAgent 作业保留在外部。这种方法对我很有效。

Why not create your database outside of Lightswitch? I don't see any advantage to directly accessing the internal Lightswitch database. In fact it sounds like a terrible idea. It's not meant to be accessed directly.

If you do it outside of Lightswitch you can do whatever you want in the DB design, include all your tables, stored procedures etc. no problem. Then finally point Lightswitch at your external database and it will pick up the Tables and Views automatically. (NOT the stored procedures).

For scheduling things to run at set times, use SQLAgent Jobs within SQLServer (assuming its SQLServer you are using). This also is done completely outside of Lightswitch.

The restrictions of Lightswitch seem to nudge us away from stored procedures; don't fight against that. Think of Lighswitch as a very basic create/read/update/delete tool. Keep your stored procedures and scheduled jobs external as SQLAgent jobs. This approach has worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文