数据库问题总结

整理了数据库相关的问题,如:分页查询、参数化查询、连接池等

1. 数据库参数化查询#

对于 Access ,参数顺序与列顺序一致,使用 ? 作为占位符,不支持命名参数

MySQL 支持命名参数,顺序可以打乱

2. 分页查询#

select * from (
  select pageSize * from (
    select (pageNumber*pageSize) * from table_xxx
    order by xxx
  ) order by xxx
) order by xxx
select * from table_xxx order by xxx
limit pageSize offset (pageNumber*pageSize)

3. Access 数据库连接池配置#

如果是使用 Visual Studio 开发,可以通过 工具 -> 连接到数据库 添加一个 Access 连接,并在高级选项中调整“池”的配置,如 EnableAll 或者 ResoucePooling 。其他值未做测试。

对应的连接字符串为:

// EnableAll
OLE DB Services=-1

// ResourcePooling
OLE DB Services=1
Default services enabled Value in connection string
All services (default) OLE DB Services = -1;
All except pooling and automatic transaction enlistment OLE DB Services = -4;
All except Client Cursor Engine OLE DB Services = -5;
All except pooling, automatic transaction enlistment, and Client Cursor Engine OLE DB Services = -8;
Pooling and automatic transaction enlistment only, session level aggregation only OLE DB Services = 3;
No services OLE DB Services = 0;

❤️ 如果这篇文章对你有帮助,欢迎赞助支持我继续维护 ❤️

☕ Support me ⚡ 爱发电赞助