all groups > sql server odbc > january 2004 >
You're in the

sql server odbc

group:

CDatabase::OpenEx( "ODBC; ...") question


CDatabase::OpenEx( "ODBC; ...") question Lisa Pearlson
1/13/2004 6:13:57 PM
sql server odbc:
CDatabase::GetConnect() returns "ODBC; ..."

However, CDatabase::OpenEx() may not include "ODBC;". It will fail to
connect if it has that prefix.

So you can not simply do:

{
CDatabase a, b;
a.OpenEx("..."); // assume this connects fine.
// try another connection to the same.
b.OpenEx( a.GetConnect() ); // fails: Data source name not found and no
default driver specified
}

I must remove the "ODBC;" prefix.. Why this intolerance? This is cumbersome!
This means I can not simply store GetConnect() string to resource and open a
new DB connection using it.
I guess I can use Open() instead of OpenEx() but that sucks too.

Re: CDatabase::OpenEx( "ODBC; ...") question TT (Tom Tempelaere)
1/14/2004 12:45:24 AM
[quoted text, click to view]

You could perhaps write a function that extracts the fields you want.
b.OpenEx( to_conn_str(a.GetConnect()) );

Tom.

Re: CDatabase::OpenEx( "ODBC; ...") question Lisa Pearlson
1/14/2004 5:59:04 PM
Yep, I did.. CDBString::MinimalizeODBC( s.GetConnect() );
Better yet, probably subclass CDatabase, override the OpenEx to just remove
the ODBC;
Thanks.

"TT (Tom Tempelaere)" <_N_OSPAMtiti____@hotmail.comMAPSO_N_> wrote in
message news:Ei0Nb.11053$cQ5.3537008@phobos.telenet-ops.be...
[quoted text, click to view]

AddThis Social Bookmark Button