大型数据库文件 (mdb) 在 vb.net 中加载需要时间,因此需要替代方案

发布于 2024-10-16 22:51:21 字数 485 浏览 2 评论 0原文

我在access数据库中有4k条记录。其中一个字段值每个包含约 100 行 所以另一个字段有大约 25 行。因此,数据库总大小达到约 30MB,并且使用 odbc http://www.homeandlearn.co.uk/net/nets12p5.html

并且由于数据库很大,更新任何其他小字段也需要时间

所以作为替代方案,我使用 rtf 文件(txt 文件没有保留所有换行符)。所以这些文件大约只有 5-10kb。但是对于 4k 记录和 2 个字段,我现在有 8k 文件。复制这些 8k rtf 文件需要花费大量时间,对于 5MB 的传输来说需要一个小时左右。

那么有没有其他替代方法来存储这些数据。这样它就可以移植并轻松地从 vb.net 加载/访问/更新?

I have 4k records in access database. And one of the field value contains ~100 lines each
so and one other field has ~25 lines. So total database size reaches ~30MB and it takes lot of time 15-20 seconds to load the database in vb.net using odbc http://www.homeandlearn.co.uk/net/nets12p5.html

and updating of any other small fields also takes time due to database being large

So as an alternative I used rtf file (txt files were not preserving all the newline characters). So these file are around 5-10kb only. But for 4k records and 2 fields I have now 8k files. And copying of these 8k rtf files is taking huge time for 5MB transfer it takes an hour or so.

So is there any other alternative for storage of this data. So that it will be portable and easily loaded/accessed/updated from vb.net?

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

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

发布评论

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

评论(3

美煞众生 2024-10-23 22:51:21

MDB 数据库

在此处输入图像描述

MDB 是 Access 数据库文件类型。 Access 数据库从来没有被设计用于 Web 系统的后端,它们主要用于轻型办公用途。

提高性能

为了暂时提高性能,您可以压缩和修复数据库。打开它,然后在工具菜单中找到链接。或者,您也可以以编程方式执行此操作。这应该根据数据库对其所做的更改数量合理地频繁地完成。 压缩和修复有什么作用?

此外,速度缓慢通常是低效的设计。如果您的数据库尚未完全规范化,请考虑阅读数据库规范化。这应该会显着提高性能,并且是应该学习的基本标准。

替代方案

对于 4k+ 记录,您可能应该使用专为大量数据设计的不错的数据库系统。

SQL-Server是微软公司推出的一款优秀的数据库系统。 MySQL 也是一个很好的开源替代方案。互联网上有很多关于如何连接到这些数据库的教程。

MDB Databases

enter image description here

MDB is the Access database filetype. Access databases were never designed to be used for backends of web systems, they are mainly for light office use.

Improving performance

For temporary improvement of performance, you can compact and repair the database. Open it up, and find the link in the tools menu. Alternatively you can do this programaticaly. This should be done reasonably frequently depending on the number of changes your databases has made to it. What does compact and repairing do?

Also, slowness is often a sign of inefficient design. Consider reading up on database normalisation if your database is not fully normalised. This should significantly improve performance and is an essential standard that should be learned.

Alternatives

For 4k+ records you should probably be using a decent database system designed specifically for larger amounts of data.

SQL-Server is an excellent database system from Microsoft. MySQL is also a great open source alternative. The Internet is full of tutorials on how to connect to these databases.

脸赞 2024-10-23 22:51:21

我有时也在 .net 中使用 Access 数据库。好的,我知道 MS-Access 并不是此类应用程序的最佳数据库。但简单的复杂查询以及功能齐全且众所周知的报告使 Access 成为一个良好的成本效益解决方案。

我看到了您指出的链接。这是我的第一种方法,但后来我意识到还有另一种更简单、更快的方法。我建议您以不同的方式对Access数据库进行链接。

  1. 创建一个数据集(如果您尚未创建)。
  2. 使用数据库资源管理器创建与 MS-Access 数据库的连接。
  3. 将所需的表拖放到创建的 DataSet 上(.net 将在 backStage 中为您创建设计器代码)
  4. 在代码上,创建一个 tableAdapter 对象和一个表对象:
    假设您的数据集名称为 DS1,表名称为 table01。

    语言:VB.NET
    检查数据对象的智能感知自动完成

创建一个表适配器对象和表对象(在数据集中删除数据库浏览器对象时设计)

dim table01_TA as new ds1Tableadapters.table01_tableAdapter
dim table01 as new ds1.table01dataTable

将数据库数据加载到内存表 table01

table01 = table01_TA.getData

使用 table01 执行操作(添加、更新、插入、删除、查询)
要自动生成用于更新、插入和删除的脚本,请确保您的表具有主键和正确的关系。
最后,更新表适配器。除非您这样做,否则数据库中的数据将不会更新。

table01_Ta.update(table01)

我建议您使用 LINQ 来查询数据,并使用数据表方法来添加和编辑数据。当您将databaseExplorer 表拖放到dataSet 上并保存时,会自动创建这些方法。经常压缩和修复Access数据库是值得的。

如果您有困难,请与我联系。

I'm using sometimes Access databases in .net too. Ok, MS-Access isn't the best database for this kind of application, I know. But the easy-doing complex queryes and the functional and well-knowed reports makes Access a good cost-benefit solution.

I saw the link that you've indicated. This way was my first technique, but then I realized there was another easier and faster. I suggest you to do the linkage for Access database in a different way.

  1. Create a dataSet, if you already didn't it.
  2. Create a connection to the MS-Access database using database explorer.
  3. Drag and drop your desired tables on created DataSet (.net will create the designer code for you in backStage)
  4. On code, create an tableAdapter object and a table object:
    Supose that your dataSet name is DS1 and a table name is table01.

    language: VB.NET
    check intellisense autocomplete for your dataobjects

creates a tableadapter object and table object (designed when you drop the database explorer objects in dataset)

dim table01_TA as new ds1Tableadapters.table01_tableAdapter
dim table01 as new ds1.table01dataTable

loads the database data into the on-memory table table01

table01 = table01_TA.getData

do your opperations using table01 (add, update, insert, delete, queries)
for automatic generation of scripts for update, insert and delete, make sure your table has primaryKeys and correct relationships.
finally, update the table adapter. Unless you do it, the data will not be updated in the database.

table01_Ta.update(table01)

I suggest you use LINQ to query your data, and the datatable methods to adding and editing data. These methods are created automatically when you drop the databaseExplorer tables on dataSet and save it. Its worth to compact and repair Access database frequently.

Contat-me if you have troubles.

江城子 2024-10-23 22:51:21

我同意汤姆的建议。给自己找一个像样的数据库服务器。但是,从您对性能问题的描述来看,您似乎还有其他严重的问题,这些问题可能很难在这里解决。

I agree with Tom's recommendation. Get yourself a decent database server. However, judging by your description of your performance issues it seems like you have other serious problems which are probably going to be difficult to resolve here.

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