打开连接池时打开第二个连接时SQL Native Client崩溃了?

时间:2022-01-06 13:22:18

I'm working with a C++ application that uses SQL Native Client to communicate via ODBC with a SQL Server 2000 database.

我正在使用C ++应用程序,该应用程序使用SQL Native Client通过ODBC与SQL Server 2000数据库进行通信。

Before doing any database work, I allocate an environment handle as follows:

在进行任何数据库工作之前,我按如下方式分配环境句柄:

retcode = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &EnvironmentHandle );

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 );

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.

SQLSetEnvAttr(包含在内)返回一个好的代码,表示成功。但是,它会导致我的应用程序第二次调用SQLDriverConnect以建立与数据库的连接时崩溃(注意:第一次连接将使用SQLDriverConnect创建,并且此时使用SQLDisconnect断开连接。)如果我评论此行,申请没有遇到麻烦。

What might be causing this?

可能是什么导致了这个?

2 个解决方案

#1


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

您是否有任何机会遇到此人遇到的同样问题:http://www.mydatabasesupport.com/forums/ms-sqlserver/218008-2003-cluster-sql-2000-connection-pooling-causes-crash.html

#2


This could be completely different problem (i.e. I don't use C++) , but maybe it helps you.

这可能是完全不同的问题(即我不使用C ++),但也许它可以帮助你。

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.

这是不同的,但可能与您的情况有关。

#1


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

您是否有任何机会遇到此人遇到的同样问题:http://www.mydatabasesupport.com/forums/ms-sqlserver/218008-2003-cluster-sql-2000-connection-pooling-causes-crash.html

#2


This could be completely different problem (i.e. I don't use C++) , but maybe it helps you.

这可能是完全不同的问题(即我不使用C ++),但也许它可以帮助你。

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.

这是不同的,但可能与您的情况有关。