SQLSetConnectAttr
函数定义:
用法类似于SQLSetEnvAttr,该函数是设置连接的各项属性用的
SQLRETURN SQLSetConnectAttr(
SQLHDBC ConnectionHandle,
SQLINTEGER Attribute,
SQLPOINTER ValuePtr,
SQLINTEGER StringLength);
参数详解:
ConnectionHandle :输入变量
连接的句柄
Attribute :输入变量 ValuePtr :输入变量
Attribute |
ValuePtr contents |
SQL_ATTR_ACCESS_MODE |
SQL_MODE_READ_ONLY 设置为只读连接,update类似的操作都是不能在他下属的stmt中执行的,只能支持查询语句。 SQL_MODE_READ_WRITE 默认值,可读可写 |
SQL_ATTR_ASYNC_ENABLE |
该连接下属的stmthandle所执行的语句可以异步处理 SQL_ASYNC_ENABLE_OFF = Off 默认值关闭异步处理 SQL_ASYNC_ENABLE_ON = On 开启异步处理 |
SQL_ATTR_AUTO_IPD |
不好意思说实话没搞懂这个是啥,如果有知道的大佬麻烦留言一下,我加上去帮助到更多的人 A read-only SQLUINTEGER value that specifies whether automatic population of the IPD after a call to SQLPrepare is supported: SQL_TRUE = Automatic population of the IPD after a call to SQLPrepare is supported by the driver. SQL_FALSE = Automatic population of the IPD after a call to SQLPrepare is not supported by the driver. Servers that do not support prepared statements will not be able to populate the IPD automatically. If SQL_TRUE is returned for the SQL_ATTR_AUTO_IPD connection attribute, the statement attribute SQL_ATTR_ENABLE_AUTO_IPD can be set to turn automatic population of the IPD on or off. If SQL_ATTR_AUTO_IPD is SQL_FALSE, SQL_ATTR_ENABLE_AUTO_IPD cannot be set to SQL_TRUE. The default value of SQL_ATTR_ENABLE_AUTO_IPD is equal to the value of SQL_ATTR_AUTO_IPD. This connection attribute can be returned by SQLGetConnectAttr but cannot be set by SQLSetConnectAttr. |
SQL_ATTR_AUTOCOMMIT |
设置是否自动提交: SQL_AUTOCOMMIT_OFF 关闭自动提交,可以手动commit或者rollback SQL_AUTOCOMMIT_ON 自动提交开启,一但执行会自动commit |
SQL_ATTR_CONNECTION_DEAD (ODBC 3.5) |
终止连接 SQL_CD_TRUE关闭连接 SQL_CD_FALSE保持连接 |
SQL_ATTR_CONNECTION_TIMEOUT |
除了查询与登录外的操作超时时长,单位为秒,整型。默认为0秒,意思不是执行sql语句立马超时而是不会超时,一直等待语句完成才向后执行 |
SQL_ATTR_CURRENT_CATALOG |
一个包含database名称的字符串指针。 |
SQL_ATTR_LOGIN_TIMEOUT |
设置登录超时时长,同SQL_ATTR_CONNECTION_TIMEOUT |