SQLSetConnectAttr
函数定义:
用法类似于SQLSetEnvAttr,该函数是设置连接的各项属性用的
SQLRETURN SQLSetConnectAttr(
SQLHDBC 秒超时,连接正常)
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_LOGIN_TIMEOUT,(void*)5,0);
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
2. 设定建立数据库连接(只读)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_ACCESS_MODE,(void*)SQL_MODE_READ_ONLY,0);
3. 设定连接异步属性(关闭异步)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_ASYNC_ENABLE,(void*)SQL_ASYNC_ENABLE_OFF,0);
4. 设定连接自动提交属性(自动提交)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_AUTOCOMMIT,(void*)SQL_AUTOCOMMIT_ON,0);
5. 设定连接请求超时时间(设置 请求超时)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_CONNECTION_TIMEOUT,(void*)3600,0);
6. 设定连接当前库(设置 当前库)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_CURRENT_CATALOG,(void*)"SYSTEM",SQL_NTS);
7. 设定连接CATALOG函数参数(设置启用标识符)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_METADATA_ID,(void*)SQL_FALSE,0);
8. 设定连接游标参数(设置启用游标据需要)
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_ODBC_CURSORS,(void*)SQL_CUR_USE_IF_NEEDED,0);
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
9. 设定连接游标参数(设置启用ODBC游标)
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_ODBC_CURSORS,(void*)SQL_CUR_USE_ODBC,0);
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
10. 设定连接游标参数(设置启用驱动游标)
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_ODBC_CURSORS,(void*)SQL_CUR_USE_DRIVER,0);
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
11. 设定连接包大小(设置包大小)
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_PACKET_SIZE,(void*)2000,0);
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
12. 设定连接对话框(设置空指针句柄)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_QUIET_MODE,(void*)NULL,0);
13. 设定连接包对话框(设置句柄)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_QUIET_MODE,(void*)ht,0);
14. 设定连接不启用跟踪(设置不启用)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_TRACE,(void*)SQL_OPT_TRACE_OFF,0);
15. 设定连接启用跟踪(设置启用)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_TRACE,(void*)SQL_OPT_TRACE_ON,0);
16. 设定连接跟踪路径(设置路径)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_TRACEFILE,(void*)"PATH",SQL_NTS);
17. 设置连接转化字符集的动态库路径
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_TRANSLATE_LIB,(void*)"PATH_DLL_NAME",SQL_NTS);
18. 设置连接转化字符集的参数
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_TRANSLATE_OPTION,(void*)1,0);
19. 设置连接事务隔离级别(读未提交)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_TXN_ISOLATION,(void*)1,0);
20. 设置连接事务隔离级别(读已提交)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_TXN_ISOLATION,(void*)2,0);
21. 设置连接事务隔离级别(可重复读)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_TXN_ISOLATION,(void*)4,0);
22. 设置连接事务隔离级别(串行化)
rs_c = SQLConnect(hdbc,(UCHAR*)szDSN,SQL_NTS,(UCHAR*)szUID ,SQL_NTS,(UCHAR*)szAuthStr,SQL_NTS);
rs = SQLSetConnectAttr(hdbc,SQL_ATTR_TXN_ISOLATION,(void*)8,0);