Link to home
Start Free TrialLog in
Avatar of eugeneng
eugeneng

asked on

VC++ ODBC connection-how to open the database connection globally??

I've used the VC++ wizard to connect to the database and generated some classes. Understand that each time I want to query a table, I have to call the Open(),OpenDataSource(), and OpenRowset() functions, which will open the database connection and fetch the rowset. When finished using the table, I will call Close() to close the table as well as the database connection. My question is, I don't want to close the database connection, I want the connection remain opened so next time when I query the table or other table (class) in the same database, I don't have to open the database connection again (which will take some time if I reopen the database connection).

I used to move the CSession m_session to a global variable, but it crashes when I exit the function!!
so how can I make the database connection to a global object. One thing maybe I should mention, I'm writing dll, not exe.
ASKER CERTIFIED SOLUTION
Avatar of cediger
cediger

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial