如何在 MS Access 中设置开发环境

发布于 2024-07-21 08:48:29 字数 992 浏览 12 评论 0 原文

我创建了一个 MS Access 2003 应用程序,设置为分离的前端/后端配置,用户组大约有 5 人。 前端 .mdb 位于网络文件服务器上,它包含所有查询、表单、报告和 VBA 代码,以及到后端 .mdb 中所有表的链接以及一些到 ODBC 数据源(如 AS/)的链接。 400。 后端位于同一网络文件服务器上,其中只有表数据。

这一直运行良好,直到我“上线”并且我的少数用户开始提出增强请求、错误报告等。我一直在通过在我自己的前端 .mdb 副本中开发/测试来推出新代码另一个网络文件夹(链接到同一个后端 .mdb),然后将我完成的文件发布到“come-and-get-it”文件夹中,提醒用户,然后他们去复制/粘贴新的前端文件保存到网络上自己的文件夹中。 这样,每个用户都可以在处于“停止点”时更新他们的前端,而不必立即将所有人引导出去。

我发现现在开发的时候Access有时会变得特别慢。 例如,当我开发表单并尝试单击属性框上的下拉菜单时,下拉箭头将推入,但需要几秒钟才能出现选项列表。 或者在选择和选择方面存在大量滞后。 在窗体上移动控件。 或者键盘有很多延迟。

然后,在其他时候,根本没有延迟。

我想知道是否是因为我与其他用户链接到相同的后端。 我确实做出了合理的努力来设置查询、表单、报告等,并根据需要使用最少的记录锁定(如果有的话)。 但我可能错过了一些东西,或者可能还有其他一些我需要解决的性能问题。

但我想知道是否有更好的方法来设置我自己的开发后端 .mdb,这样我就可以在“安全”数据上测试我的代码,而不是与其他用户相同的实时数据。 恐怕我损坏一些数据只是时间问题,可能是在最糟糕的时刻。

显然,我可以设置一个单独的后端 .mdb,并使用链接表管理器每次手动重新配置前端中的表链接。 但我希望有一个比这更优雅的解决方案。

我想知道在这个多用户、拆分数据库配置中是否应该考虑任何其他性能问题。

编辑:我应该补充一点,我坚持使用 MS Access(不是 MS-SQL 或任何其他“真正的”后端); 有关更多详细信息,请参阅我对此帖子的评论。

I have created an MS Access 2003 application, set up as a split front-end/back-end configuration, with a user group of about five people. The front end .mdb sits on a network file server, and it contains all the queries, forms, reports, and VBA code, plus links to all the tables in the back end .mdb and some links to ODBC data sources like an AS/400. The back end sits on the same network file server, and it just has the table data in it.

This was working well until I "went live" and my handful of users started coming up with enhancement requests, bug reports, etc. I have been rolling out new code by developing/testing in my own copy of the front-end .mdb in another network folder (which is linked to the same back-end .mdb), then posting my completed file in a "come-and-get-it" folder, alerting the users, and they go copy/paste the new front-end file to their own folders on the network. This way, each user can update their front end when they're at a 'stopping point' without having to boot everyone out at once.

I've found that when I'm developing now, sometimes Access becomes extremely slow. Like, when I am developing a form and attempt to click a drop-down on the properties box, the drop-down arrow will push in, but it will take a few seconds before the list of options appears. Or there's tons of lag in selecting & moving controls on a form. Or lots of keyboard lag.

Then, at other times, there's no lag at all.

I'm wondering if it's because I'm linked to the same back end as the other users. I did make a reasonable effort to set up the queries, forms, reports etc. with minimal record locking, if any at all, depending on the need. But I may have missed something, or perhaps there is some other performance issue I need to address.

But I'm wondering if there is an even better way for me to set up my own development back-end .mdb, so I can be testing my code on "safe" data instead of the same live data as the rest of the users. I'm afraid that it's only a matter of time before I corrupt some data, probably at the worst possible moment.

Obviously, I could just set up a separate back-end .mdb and manually reconfigure the table links in the front end every time, using the Linked Table Manager. But I'm hoping there is a more elegant solution than that.

And I'm wondering if there are any other performance issues I should be considering in this multi-user, split database configuration.

EDIT: I should have added that I'm stuck with MS Access (not MS-SQL or any other "real" back end); for more details see my comment to this post.

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

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

发布评论

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

评论(8

熟人话多 2024-07-28 08:48:29

如果您的所有用户都共享前端,那就是错误的配置。

每个用户都应该有一个单独的前端副本。 共享前端肯定会导致共享前端频繁损坏,以及前端表单和模块的奇怪损坏。

我不清楚如何在最终用户正在使用的前端副本中进行开发,因为从 A2000 开始,这是被禁止的(因为“整体保存模型”,其中存储了整个 VBA 项目)在系统表之一的单个记录的单个 BLOB 字段中)。

我真的不认为问题是由使用生产数据引起的(尽管正如其他人所说,针对生产数据进行开发可能不是一个好主意)。 我认为它们是由糟糕的编码实践和前端代码缺乏维护造成的。

  1. 在 VBE 选项中关闭 COMPILE ON DEMAND。

  2. 确保您需要 OPTION EXPLICIT。

  3. 每隔几行代码就经常编译您的代码 - 为了使这变得简单,请将 COMPILE 按钮添加到您的 VBE 工具栏(当我这样做时,我还添加了 CALL STACK 按钮)。

  4. 定期备份前端并反编译和重新编译代码。 这是通过使用 /decompile 开关启动 Access,打开前端,关闭 Access,使用 Access 打开前端(按住 SHIFT 键以绕过启动代码),然后压缩反编译的前端(使用 SHIFT按住键),然后编译整个项目并最后一次压缩。 您应该在任何主要代码发布之前执行此操作。

其他一些想法:

  1. 你没有说它是否是 Windows 服务器。 通过 SAMBA 访问的 Linux 服务器过去曾出现过问题(尽管有些人坚信它们并说它们比 Windows 服务器快得多),并且历史上 Novell 服务器需要调整设置才能可靠地编辑 Jet 文件。 还有一些设置(如 OPLOCKS)可以在 Windows 服务器上进行调整,以使事情更好地工作。

  2. 将您的 Jet MDB 存储在具有短路径的共享中。 \Server\Data\MyProject\MyReallyLongFolderName\Access\Databases\ 读取数据的速度比 \Server\Databases 慢得多。 这确实产生了巨大的差异。

  3. 链接表存储的元数据可能会过时。 有两个简单的步骤和一个激烈的步骤来解决这个问题。 首先压实后端,然后压实前端。 这是最简单的一个。 如果这没有帮助,请完全删除链接并从头开始重新创建它们。

  4. 您还可以考虑将 MDE 而不是 MDB 分发给最终用户,因为它无法反编译(MDB 可以)。

  5. 请参阅Tony Toews 的性能常见问题解答,了解其他一般性能信息。

If all your users are sharing the front end, that's THE WRONG CONFIGURATION.

Each user should have an individual copy of the front end. Sharing a front end is guaranteed to lead to frequent corruption of the shared front end, as well as odd corruptions of forms and modules in the front end.

It's not clear to me how you could be developing in the same copy of the front end that the end users are using, since starting with A2000, that is prohibited (because of the "monolithic save model," where the entire VBA project is stored in a single BLOB field in a single record in one of the system tables).

I really don't think the problems are caused by using the production data (though it's likely not a good idea to develop against production data, as others have said). I think they are caused by poor coding practices and lack of maintainance of your front end code.

  1. turn off COMPILE ON DEMAND in the VBE options.

  2. make sure you require OPTION EXPLICIT.

  3. compile your code frequently, after every few lines of code -- to make this easy, add the COMPILE button to your VBE toolbar (while I'm at it, I also add the CALL STACK button).

  4. periodically make a backup of your front end and decompile and recompile the code. This is accomplished by launching Access with the /decompile switch, opening your front end, closing Access, opening your front end with Access (with the SHIFT key held down to bypass the startup code), then compacting the decompiled front end (with the SHIFT key held down), then compiling the whole project and compacting one last time. You should do this before any major code release.

A few other thoughts:

  1. you don't say if it's a Windows server. Linux servers accessed over SAMBA have exhibited problems in the past (though some people swear by them and say they're vastly faster than Windows servers), and historically Novell servers have needed to have settings tweaked to enable Jet files to be reliably edited. There are also some settings (like OPLOCKS) that can be adjusted on a Windows server to make things work better.

  2. store your Jet MDBs in shares with short paths. \Server\Data\MyProject\MyReallyLongFolderName\Access\Databases\ is going to be much slower reading data than \Server\Databases. This really makes a huge difference.

  3. linked tables store metadata that can become outdated. There are two easy steps and one drastic one to be taken to fix it. First, compact the back end, and then compact the front end. That's the easy one. If that doesn't help, completely delete the links and recreate them from scratch.

  4. you might also consider distributing an MDE to your end users instead of an MDB, as it cannot uncompile (which an MDB can).

  5. see Tony Toews's Performance FAQ for other generalized performance information.

虐人心 2024-07-28 08:48:29

1)从代码重新链接访问表
http://www.mvps.org/access/tables/tbl0009.htm

一旦我准备好向用户发布新的 MDE,我就会重新链接表、创建 MDE 并将 MDE 复制到服务器。

2) 我专门创建了免费的 Auto FE Updater 实用程序,以便我可以根据需要经常更改 FE MDE,并且非常有信心下次有人运行该应用程序时它会拉入最新版本。 有关错误或自动 FE 更新程序实用程序的详细信息,请参阅免费的自动 FE 更新程序实用程序,网址为 http://www.granite.ab.ca/access/autofe.htm 在我的网站上,以使每台电脑上的 FE 保持最新。

3)现在,当我在客户现场工作时,当每个人都离开系统时,我会在下班后更新表结构。 请参阅如何:在 Access 2000 中检测用户空闲时间或不活动 (Q210297) http://support.microsoft .com/?kbid=210297 ACC:如何检测用户空闲时间或不活动 (Q128814) http://support.microsoft.com/?kbid=128814

但是我们发现程序员必须禁用在计时器事件上运行的代码。 否则,当您编辑代码时,奇怪的事情就会开始发生。

此外,打印预览有时不允许用户运行菜单项将报告导出到 Excel 或其他文件。 因此,您必须右键单击预览的报告才能将某种类型的内部焦点重新集中到报告上,以便他们可以将其导出。 将计时器延长至五分钟也对此有所帮助。

将计时器延长到五分钟的缺点是,如果一个人在一天的相当长的时间里保持相同的形式和相同的控制,即某人进行相同的查询,则例程不会意识到他们实际上已经做了某件事。 当他们在程序中执行某些操作时,我有时会加入一些逻辑来重置此计时器。

4)参考另一个人评论脚本等更新架构,请参阅Compare'Em http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEM.htm。 虽然它有其怪癖,但它确实创建了 VBA 代码来更新表、字段、索引和关系。

1) Relink Access tables from code
http://www.mvps.org/access/tables/tbl0009.htm

Once I'm ready to publish a new MDE to the users I relink the tables, make the MDE and copy the MDE to the server.

2) I specifically created the free Auto FE Updater utility so that I could make changes to the FE MDE as often as I wanted and be quite confident that the next time someone went to run the app that it would pull in the latest version. For more info on the errors or the Auto FE Updater utility see the free Auto FE Updater utility at http://www.granite.ab.ca/access/autofe.htm at my website to keep the FE on each PC up to date.

3) Now when working on site at a clients I make the updates to the table structure after hours when everyone is out of the system. See HOW TO: Detect User Idle Time or Inactivity in Access 2000 (Q210297) http://support.microsoft.com/?kbid=210297 ACC: How to Detect User Idle Time or Inactivity (Q128814) http://support.microsoft.com/?kbid=128814

However we found that the code which runs on the timer event must be disabled for the programmers. Otherwise weird things start happening when you're editing code.

Also print preview would sometimes not allow the users to run a menu item to export the report to Excel or others. So you had to right click on the Previewed report to get some type of internal focus back on the report so they could then export it. This was also helped by extending the timer to five minutes.

The downside to extending the timer to five minutes was if a person stays in the same form and at the same control for considerable parts of the day, ie someone doing the same inquiries, the routine didn't realize that they had actually done something. I'll be putting in some logic sometime to reset this timer whenever they do something in the program.

4) In reference to another person commenting about scripts and such to update the schema see Compare'Em http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEM.htm. While it has its quirks it does create the VBA code to update tables, fields, indexes and relationships.

吻安 2024-07-28 08:48:29

从开发切换到生产时,使用 VBA 取消链接并将表重新链接到新目标。 我已经记了很多年的语法了——我只知道这个函数写起来很简单。

或者使用 MS-Access 通过 ODBC 或客户端 mdb 外部的某些其他数据连接与 MS-Access 进行通信。

与所有文件库数据库一样,您最终会遇到使用高峰或超过 2 到 30 之间的小神奇数字时出现的问题。

此外,Access 往往会频繁损坏,因此需要在以下位置进行备份、压缩和修复:频繁的基础。 曾经存在第三方工具来自动执行此任务。

就性能而言,数据正在客户端进行处理,因此您可能需要使用 netmeter 之类的工具来观察有多少数据正在通过网络传输。 关于索引和避免表扫描的相同原则也适用于文件数据库。

Use VBA to unlink and re-link your tables to the new target when switching from dev to prod. It's been to many years for me to remember the syntax--I just know the function was simple to write.

Or use MS-Access to talk to MS-Access through ODBC, or some other data connection that lives outside of the client mdb.

As with all file base databases, you will eventually run into problems with peak usage or when you go over a small magical number somewhere between 2 and 30.

Also, Access tends to corrupt frequently, so backup, compact and repair need to be done on an frequent basis. 3rd party tools used to exist to automate this task.

As far as performance goes, the data is being processed client side, so you might want to use something like netmeter to watch how much data is going over the wire. The same principle about indexing and avoiding table scans apply to file base dbs as well.

对你的占有欲 2024-07-28 08:48:29

其他人的许多好建议。 这是我的2毫分的价值。 我的后端数据位于通过驱动器映射访问的服务器上。 就我而言,是 Y 驱动器。 生产用户使用活动目录通过登录脚本获取映射。 然后,通过批处理文件可以轻松完成以下场景:

  • 通过在批处理文件中执行 subst 命令来针对本地计算机进行开发
  • 通过将 Y 指向备份服务器(只读)来针对昨晚的数据运行报告
  • 通过指向月末数据来运行报告到正确的目录
  • 通过保留特殊目录来针对特殊场景进行测试

在我的环境中(平均 5 个并发用户,1000 行,而不是 10,000 行。)发生了损坏,但这种情况很少见且易于管理。 在过去的几年里,我们只使用过一次前几天的备份。 我们使用 SQL Server 来处理更高容量的内容,但开发起来并不方便,可能是因为我们现场没有 SQL 管理员。

Many good suggestions from other people. Here's my 2 millicents worth. My backend data is on server accessed through a Drive mapping. In my case, the Y drive. Production users get the mapping through a login script using active directory. Then the following scenarios are easily done by batch file:

  • Develop against local computer by doing a subst command in a batch file
  • run reports against last nights data by pointing Y to the backup server (read only)
  • run reports against end of month data by pointing to the right directory
  • test against specialized scenarios by keeping a special directory

In my environment (average 5 simultaneous users, 1000's of rows, not 10,000's.) corruption has occurred, but it's rare and manageable. Only once in the last several years have we resorted to the previous days backup. We use SQL Server for our higher volume stuff, but it's not as convenient to develop against, probably because we don't have a SQL admin on site.

撩发小公举 2024-07-28 08:48:29

您可能还会找到 这个问题(如何从访问中提取模式)也很有用。 一旦您使用建议的技术之一提取了模式,您将获得一系列新选项,例如对模式使用源代码控制的能力,以及能够轻松构建“干净”的测试环境。

编辑以回复评论:
没有简单的方法可以对 Access 数据库的本机格式进行源代码控制,但架构文件与其他文件一样只是文本文件。 因此,您可以将它们签入和签出您选择的源代码控制软件,以便轻松进行版本控制/回滚。

当然,它依赖于您设置了一系列脚本来从架构重建数据库。 一旦完成,创建一个在不同位置重建它的选项/替代版本通常相当简单,允许您从任何先前提交的模式版本构建测试环境。 我希望这能澄清一点!

You might also find some of the answers to this question (how to extract schemas from access) to be useful as well. Once you've extracted a schema using one of the techniques that were suggested you gain a whole range of new options like the ability to use source control on the schemas, as well as being able to easily build "clean" testing environments.

Edit to respond to comment:
There's no easy way to source control an Access database in it's native format, but schema files are just text files like any other. Hence, you can check them in and out of the source control software of your choice for easy version control/rollbacks.

Or course, it relies on you having a series of scripts set up to re-build your database from the schema. Once you do, it's normally fairly trivial to create an option/alternative version that rebuilds it in a different location, allowing you to build test environments from any previous committed version of the schema. I hope that clarifies a bit!

她如夕阳 2024-07-28 08:48:29

如果您想在向客户端发布新的 FE 时自动更新后端 MDB 架构,请参阅 Compare'Em http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEM.htm 将很乐意生成重新创建 MDB 所需的 VBA 代码。 或者创建两个 MDB 之间差异的代码,以便您可以对现有的 BE MDB 进行版本升级。 这有点奇怪但有效。

我用它所有的时间。

If you want to update the back end MDB schema automatically when you release a new FE to the clients then see Compare'Em http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEM.htm will happily generate the VBA code need to recreate an MDB. Or the code to create the differences between two MDBs so you can do a version upgrade of the already existing BE MDB. It's a bit quirky but works.

I use it all the time.

怪异←思 2024-07-28 08:48:29

您需要了解数据的共享 mdb 文件并不是一个可靠的解决方案。 Microsoft 建议 SQL Server 或其他一些基于服务器的数据库将是更好的解决方案,并且允许您使用相同的访问前端。 如果您想这样做,迁移向导将帮助您进行转换。

正如另一个用途所指出的,腐败将会发生。 这只是一个多久一次的问题,而不是是否会这样的问题。

要了解性能问题,您需要了解对于服务器来说,包含数据的 mdb 文件只是一个文件。 由于服务器上没有运行任何代码,因此服务器不理解事务、记录锁定等。它只知道有一个文件,一群人正在尝试同时读写。

拥有SQL Server、Oracle、DB2等数据库系统。 MySQL等数据库程序在服务器上运行,并且对于服务器来说就像访问数据库文件的单个程序一样。 它是数据库程序(在服务器上运行),负责处理记录锁定、事务、并发、日志记录、数据备份/恢复以及人们希望从数据库获得的所有其他好处。

由于设计在服务器上运行的数据库程序就是为了执行此操作且仅此而已,因此它比 Access 等读取和写入共享文件 (mdb) 的程序做得更好、更高效。

You need to understand that a shared mdb file for the data is not a robust solution. Microsoft would suggest that SQL Server or some other server based database would be a far better solution and would allow you to use the same access front end. The migration wizard would help you make the changeover if you wanted to go that way.

As another uses pointed out, corruption will occur. It is simply a question of how often, not if.

To understand the performance issues you need to understand that to the server the mdb file with the data in it is simply that, a file. Since no code runs on the server, the server does not understand transactions, record locking etc. It simply knows that there is a file that a bunch of people are trying to read and write simultaniously.

With a database system such as SQL Server, Oracle, DB2. MySQL etc. the database program runs on the server and looks to the server like a single program accessing the database file. It is the database program (running on the server) that handles record locking, transactions, concurrency, logging, data backup/recovery and all the other nice things one wants from a database.

Since a database program designed to run on the server is designed to do that and only that, it can do it far better and more efficently that a program like Access reading an writing a shared file (mdb).

天暗了我发光 2024-07-28 08:48:29

针对实时数据进行开发有两个规则

第一条规则是。 。 。 永远不发展
针对实时数据。 从来没有。

第二条规则是。 。 .永不发展
针对实时数据。 从来没有。

您可以通过编程方式更改链接表的绑定,以便在部署新版本时编写宏来更改链接。

该应用程序速度很慢,因为它是 MS Access,并且不喜欢许多并发用户(其中​​“许多”是任意数字 > 1)。

There are two rules for developing against live data

The first rule is . . . never develop
against live data. Not ever.

The second rule is . . .never develop
against live data. Not ever.

You can programatically change the bindings for linked tables, so you can write a macro to change your links when you're deploying a new version.

The application is slow because it's MS Access, and it doesn't like many concurrent users (where many is any number > 1).

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