Summarize database connection and operation

xiaoxiao2021-03-06  38

Yesterday, I asked two questions yesterday, the first is the opening and closing of the database connection, the second is the difference between the two types of operations. Summarize the following and my test :

Which way to open and close the database connection? Why?

1. After opening the application, each of the operations of a database opens the connection. After the operation is completed, turn off the connection, each operation is like this.

2. After opening the application, open the connection of the database for related operations, do not immediately turn off the connection immediately, continue the next operation, no need to open it, but until the application is closed.

For this problem, everyone is more agreed in the second method, but sometimes it is necessary to be used in two ways.

If there is not much client connected to the data, it is possible to consider the second method, because the connection to the database can make the subsequent operation easier.

But if you connect the database, you will be closed immediately. Of course, the connection that is often used can be maintained. In this way, you can make the database to serve customers faster.

Two differences in the operation of the database?

1.set = conn.execute (strsql)

2.rs.open strsql, conn, 1, 3

In the first way, you can get a recordset read-only, you cannot update, you can only move forward (rs.movenext), or move to the beginning of the recordset (rs.movefirst)

The second method is universal, all of the operations can be implemented, and the efficiency of the two ways should have no difference (not determined), and some people think that the second method takes more memory.

转载请注明原文地址:https://www.9cbs.com/read-75912.html

New Post(0)