开发者

Single user database connection best practices

With MS Access single user,

Is it good practice or okay to maintain a persistent connection througho开发者_StackOverflowut?

psuedocode:

app.start();
access.connect();
domanymanystuff();
access.disconnect();
app.exit();

--- OR ----

app.start();
access.connect();
doonetask();
access.disconnect();
...
access.connect();
doanothertask();
access.disconnect();
...
app.exit();

?


Honestly it won't matter since most data connection are pooled and will hang around for reuse after you have closed them. You do want to make sure that your transactions are performed in a 'per unit of work' fashion.

Otherwise, even with a single user DB you could find your application locking itself out.

So, try this:

Open connection
Start transaction
Perform unit of work
Commit transaction
...    
Start transaction
Perform unit of work
Commit transaction
...    
Start transaction
Perform unit of work
Commit transaction
...
Close connection


You can maintain a persistent connection throughout with a single-user database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜