Access 2003中可以制作存储过程或函数吗?

发布于 2024-11-01 20:35:05 字数 36 浏览 1 评论 0原文

在Access 2003中,我们可以创建存储过程或函数吗?

In Access 2003, can we create stored procedure or function?

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

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

发布评论

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

评论(2

静谧 2024-11-08 20:35:05

对于 Access 2003,答案是否定的。

Access 2010 确实有表触发器和存储过程。这些是真正的引擎级例程,作为行更新的结果运行。因此,导致行修改的表单或 VBA 记录集代码或 SQL 更新将导致存储过程和表级代码运行。事实上,即使是通过 ODBC 从 vb.net 甚至 VB6 进行外部连接也会导致这些存储过程运行。

但是,在 Access 2010 之前,如果使用默认数据库引擎,则没有存储过程。但是,您可以为 Access 应用程序选择与 JET 不同的数据引擎,当您这样做时,您可以拥有存储过程,但您必须使用您选择与 Access 一起使用的任何数据库引擎附带的工具。因此,请记住,就像构建网站一样,您可以出去选择使用的数据库引擎。对于 ms-access 也是如此,您可以自由地选择一个具有与 Access 一起使用的存储过程的数据库引擎。

如前所述,例外情况是 Access 2010 现在确实具有表级触发器和存储过程。

For Access 2003, the answer is no.

Access 2010 does have table triggers and store procedures. These are true engine level routines that run as a result of row updates. So forms or VBA recordset code or sql updates that cause a row modify will cause the store procedure and table level code to run. In fact, even external connections via ODBC from vb.net, or even VB6 will cause these store procedures to run.

However prior to Access 2010 you do not have store procedures if you use the default database engine. However, you can choose a different data engine then JET for your Access applications and when you do this then yes you can have store procedures, but you have to use the tools that come with whatever data base engine you have chosen to use with Access. So, keep in mind that just like when you build a web site, you then can go out and choose what database engine you use. The same goes for ms-access and you are free to go out and choose a database engine that has store procedures to be used with Access.

As noted, the exception to this is that Access 2010 does have table level triggers and store procedures now.

风追烟花雨 2024-11-08 20:35:05

不是“存储过程”本身。您可以创建保存的查询并从 Access 中调用这些查询,就像从 Sql Server 中调用存储过程一样。已保存查询的限制是您无法使用流代码控制(例如 If Else 或 Case When),并且一次只能保存一个命令。

创建已保存查询的最简单方法是打开 Access,转到“查询”选项卡并在“设计视图”中创建一个新查询。关闭“显示表”对话框并切换到“SQL 视图”。使用上面的示例,键入 SQL 子句的第一部分:

    INSERT INTO Addresses ( Organisationname, AddressLine1, AddressLine2,
    AddressLine3, City, StateCounty, CountryID, PostCodeZip, SwitchboardNo,
    FaxNo, Email, Website, RecordStatus, LastUpdated, LastUpdateBy )
    Values

现在打开括号并创建参数占位符。它们始终位于方括号 ([]) 中,这告诉 Access 需要一个值作为参数。您可以将任何您喜欢的内容放在方括号内。 [p1]、[p2]、[p3] 等是我的选择,因此最终查询将如下所示:

    INSERT INTO Addresses ( Organisationname, AddressLine1, AddressLine2,
    AddressLine3, City, StateCounty,CountryID, PostCodeZip, SwitchboardNo, FaxNo, 
    Email, Website, RecordStatus, LastUpdated, LastUpdateBy ) Values ([p1],[p2],[p3],
    [p4],[p5],[p6],[p7],[p8],[p9],[p10],[p11],[p12], [p13],[p14],[p15]);

如果运行查询,Access 将提示您输入每个字段。针对每个字段输入数据以测试查询是否有效。至于调试,你已经完成了。将查询保存为有意义的内容。该地址保存为 qUpdateAddresses。保存时,您可能会注意到 Access 自动检测到这是追加查询。验证其有效后,关闭数据库。

要从 ASP.NET 运行它,请查看这篇文章,注意最后标题为“已保存的查询”的部分:
http://www.mikesdotnetting.com /Article.aspx?ArticleID=26

Not "Stored Procedures" as such. You can create saved queries and call those from Access in the same way as stored procs form Sql Server. The limitations that the saved queries have are that you cannot use control of flow code (such as If Else or Case When) and you can only save one command at a time.

The simplest way to create saved queries is to open up Access, go the Query tab and create a new query in Design View. Close the Show Tables dialogue box and switch to SQL View. Using the example above, type in the first part of the SQL clause:

    INSERT INTO Addresses ( Organisationname, AddressLine1, AddressLine2,
    AddressLine3, City, StateCounty, CountryID, PostCodeZip, SwitchboardNo,
    FaxNo, Email, Website, RecordStatus, LastUpdated, LastUpdateBy )
    Values

Now open the brackets and create the parameter place holders. These are always in square brackets ( [ ] ), which tells Access to expect a value as a parameter. You can put anything you like within the square brackets. [p1], [p2], [p3] etc are my choice, so the final query will look like this:

    INSERT INTO Addresses ( Organisationname, AddressLine1, AddressLine2,
    AddressLine3, City, StateCounty,CountryID, PostCodeZip, SwitchboardNo, FaxNo, 
    Email, Website, RecordStatus, LastUpdated, LastUpdateBy ) Values ([p1],[p2],[p3],
    [p4],[p5],[p6],[p7],[p8],[p9],[p10],[p11],[p12], [p13],[p14],[p15]);

If you Run the query, Access will prompt you for input for each field. Enter data against each field to test that the query is working. As for debugging, you've just done it. Save the query as something meaningful. This one is saved as qUpdateAddresses. As you save it, you may notice that Access automatically detects that this is an Append Query. Once you have verified that it works, close the database.

to run it from ASP.NET, look at this article, paying attention to the bit towards the end that's headed "Saved Queries":
http://www.mikesdotnetting.com/Article.aspx?ArticleID=26

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