I am creating an application using MFC that accesses a sybase database on a sybase server through ODBC. The application creates a CDatabase object at start up, calls its Open() member function and then passes its address as an argument to about 20 recordsets. I have a stored procedure on the sybase server that shows me the number of connections to the database. When I use it, I find that I have 15 database connections, one for each recordset!! Of-course, this is not acceptable as the lisence ofthe database engine restricts the number of connections. After some investigations, I discovered that, when I pass a pointer to a connected CDatabase object to the constructor of the first recordset, it uses this connection as expected. Each recordset after the first one ignores the open database connection and creates a new connection for itself!! All the recordsets are of type snapshot.
I am sure that there is a solution but, I don’t know it!! The reason I am sure is that, I created a simpledatabase using Microsoft Access that connects to the same sybase ODBC data source. I tried to open many tables concurrently and checked the number of database connections. There is ONLY ONE!! This is exactly what I want to do from Visual C++ but I cannot. Would you please help me??
Thanks in advance.