在C#中打开和关闭MS Access DB [英] Opening and Closing MS Access DB in C#

查看:142
本文介绍了在C#中打开和关闭MS Access DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打开一个访问数据库来更新表结构和字段。我想问一下哪种方法更好:



1.在程序开始时打开数据库进行所有更新然后在程序结束时关闭数据库。







2.打开db然后对字段进行更新然后关闭数据库。并且为每次更新执行此过程,直到我迭代所有更新。





感谢您的任何建议。

I need to open an access db to update table structure and fields. I would like to ask which approach is better:

1. Open the db at the start of the Program make ALL updates then close the db at the end of the Program.

or

2. Open db then do update on a field then close the db. And do this procedure for each update until I have iterated on all updates.


Thanks for any advise.

推荐答案

基本上,如果您的程序在表上连续进行了大量更新,那么它取决于您的程序,然后在您启动更新过程时以及更新关闭连接的所有记录后打开连接。否则,如果您的程序更新记录不是连续的,则在每次更新时打开它,然后关闭它并在新的更新时再次打开它。但是不要在程序开始时打开它。除非您的程序在启动时对数据库执行某些操作(插入,获取记录等),否则这不是个好主意。
Basically it depends on your programme if your programme makes alot of updates on the table continuously, then open the connection when you start the update process and after updating all the records close the connection. Otherwise if your programme update records not in continuous manner then open it on each update and after that close it and open it again on new update. But don't open it on the start of the programme. It's Not the good idea unless your programme perform some actions on the Database(Insert, Get Records etc.) on start.


这篇关于在C#中打开和关闭MS Access DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆