连接池打开时打开第二个连接时 SQL Native Client 崩溃?
我正在使用一个 C++ 应用程序,该应用程序使用 SQL Native Client 通过 ODBC 与 SQL Server 2000 数据库进行通信。
在执行任何数据库工作之前,我按如下方式分配环境句柄:
retcode = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &EnvironmentHandle );
此操作成功完成。
要启用连接池,在上述语句之前,我调用:
retcode = SQLSetEnvAttr( NULL, SQL_ATTR_CONNECTION_POOLING, (SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER );
SQLSetEnvAttr
(如果包含),将返回好的代码,说明成功。 但是,它会导致我的应用程序在第二次调用 SQLDriverConnect
建立与数据库的连接时崩溃(注意:第一个连接将使用 SQLDriverConnect
创建并断开连接)此时使用SQLDisconnect
。)如果我注释掉这一行,应用程序将顺利进行。
可能是什么原因造成的?
I'm working with a C++ application that uses SQL Native Client to communicate via ODBC with a SQL Server 2000 database.
Before doing any database work, I allocate an environment handle as follows:
retcode = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &EnvironmentHandle );
This completes successfully.
To enable connection pooling, BEFORE the above statement, I call:
retcode = SQLSetEnvAttr( NULL, SQL_ATTR_CONNECTION_POOLING, (SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER );
SQLSetEnvAttr
, when included, returns a good code, indicating success. However, it causes my application to crash the second time that SQLDriverConnect
is called to establish a connection to the database (note: the first connection will have been created using SQLDriverConnect
and disconnected using SQLDisconnect
by this time.) If I comment this line out, the application proceeds without trouble.
What might be causing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否遇到过与此人相同的问题:http://www.mydatabasesupport.com/forums/ms-sqlserver/218008-2003-cluster-sql-2000-connection-pooling-causes-crash.html
Are you by any chance experiencing the same problem that this person was having: http://www.mydatabasesupport.com/forums/ms-sqlserver/218008-2003-cluster-sql-2000-connection-pooling-causes-crash.html
这可能是完全不同的问题(即我不使用 C++),但也许它对您有帮助。
当我打开池化时,我正在开发的应用程序也崩溃了。
当数据库查询返回多个记录集时会出现此问题。
当我尝试移动到下一个记录集时,我的应用程序崩溃了。
这是不同的,但可能与您的情况有关。
This could be completely different problem (i.e. I don't use C++) , but maybe it helps you.
Application which I am working on also crashed when I turned pooling on.
The problem occurred when database query returned more than one record set.
My app crashed when I tried to move to the next record set.
This is something different, but could be related to your case.