简体   繁体   English

有没有一种方法来设置一个DSN ODBC连接选项?

[英]Is there a way to set ODBC Connection options in a DSN?

My application (a testcase automation tool) does not support calling ODBC's SQLSetStatmentOption . 我的应用程序(一个测试用例自动化工具)不支持调用ODBC的SQLSetStatmentOption I need to set the cursor option SQL_SOPT_SS_CURSOR_OPTIONS to SQL_CO_FFO_AF . 我需要将游标选项SQL_SOPT_SS_CURSOR_OPTIONS设置为SQL_CO_FFO_AF Right now I connect to the server using a connection string (no DSN). 现在,我使用连接字符串(无DSN)连接到服务器。 I am using sqlsrv32.dll or Sqlncl10.dll . 我正在使用sqlsrv32.dll或Sqlncl10.dll

Is there a way to set the cursor option in a DSN (or other layer) between my tool and the MSSQL server? 是否可以在我的工具和MSSQL服务器之间的DSN(或其他层)中设置光标选项? The tool handles creating the cursor (or results set) and iterating through the result set in a way that seems to obscure any ability to manage it directly. 该工具处理创建游标(或结果集)并在结果集中进行迭代的方式似乎掩盖了直接管理它的任何能力。 It does allow for calling SQLSetConnectAttr() but as far as I can tell there's no way to set a cursor option in there. 它的确允许调用SQLSetConnectAttr(),但据我所知无法在其中设置光标选项。

All of this is an attempt to speed up retrieving data over a remote connection. 所有这些都是为了加快通过远程连接检索数据的尝试。 In SQL Management Studio I get comparable response times to the local or remote DB, but in the automation tool the remote queries take hundreds of times longer, probably because it seems to be making a round trip to the sever for every row. 在SQL Management Studio中,我获得了与本地或远程DB相当的响应时间,但是在自动化工具中,远程查询花费了数百倍的时间,这可能是因为它似乎正在为每一行往返服务器。

There is no way to set statement options in the connection string that I know of. 我无法在连接字符串中设置语句选项。 In ODBC 1.0 and 2.0 you could make calls to SQLSetConnectOption for statement attributes and they set those attributes in each statement created in that connection but a) that is an old version of the API (although it probably still works) b) you still cannot do it from the DSN. 在ODBC 1.0和2.0中,您可以调用SQLSetConnectOption来获取语句属性,并且它们在该连接中创建的每个语句中设置这些属性,但是a)是API的旧版本(尽管它可能仍然有效)b)您仍然无法执行它来自DSN。 In unixODBC you can set some environment and connection attributes in the DSN but your obviously Windows. 在unixODBC中,您可以在DSN中设置一些环境和连接属性,但您可以使用Windows。

I'm not convinced anyway that you've identified the problem correctly and even if you have, how do you know your app does not use SQLGetData (which is disabled when you set SQL_CO_FFO_AF). 无论如何,我都不相信您已经正确地识别了问题,即使您知道了,您如何知道您的应用程序没有使用SQLGetData(在设置SQL_CO_FFO_AF时将其禁用)。 Are you sure you've not enabled MARs. 您确定尚未启用MAR。 Did you try getting an ODBC trace to see what the app is doing? 您是否尝试获取ODBC跟踪以查看应用程序在做什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM