Re: ODBC connection strings - "ODBC;" prefix?
- From: changliw@xxxxxxxxxxxxxxxxxxxx (Charles Wang[MSFT])
- Date: Mon, 12 Mar 2007 14:27:01 GMT
Hi, David,
Thanks for your response.
From my test, I found that this issue should be caused by SQLDriverConnectwhich does not accept "ODBC;" parameters. If you observe CDatabase::Open
method, you will find that:
if (_tcsnicmp(strConnect, _afxODBCTrail, lstrlen(_afxODBCTrail)) == 0)
{
// Strip "ODBC;"
strConnect = strConnect.Right(strConnect.GetLength()
- lstrlen(_afxODBCTrail));
}
As you can see, if there is "ODBC;" in the connection string,
CDatabase::Open method will remove it; however, CDatabase::OpenEx does not
provide this function. When you add "ODBC;" to the connection string, for
instance "ODBC;DSN=MySQL2000;Database=GT;", the parameter pszConnectInput
value of ::SQLDriverConnect method will be "DSN=MySQL2000;Database=GT;" for
CDatabase::Open method; while "ODBC;DSN=MySQL2000;Database=GT;" for
CDatabase::OpenEx.
The value with "ODBC;" will fail the driver connection. You can refer to
the nResult value.
Although MFC pre-pending the "ODBC;" after the SQLDriverConnect method, it
is just for saving the OUTPUT connection string and let us know that this
is an ODBC connection. This shoud be a by design behavior for upward
compatibility and should not be a bug.
Anyway, if you use OpenEx method, there is no need to use "ODBC;" which
will cause driver connection failure. Actually there is also no need to use
"ODBC;" in the Open method now since it will be removed even if you add the
"ODBC;" in the connection string. Also, you can see that OpenEx is called
at the end of the Open method.
Appreciate your understanding on this. If you have any other questions or
concerns, please feel free to let me know.
Have a good day!
Charles Wang
Microsoft Online Community Support
=====================================================
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
.
- Follow-Ups:
- Re: ODBC connection strings - "ODBC;" prefix?
- From: Dave Calkins
- Re: ODBC connection strings - "ODBC;" prefix?
- References:
- Re: ODBC connection strings - "ODBC;" prefix?
- From: Dave Calkins
- Re: ODBC connection strings - "ODBC;" prefix?
- From: Charles Wang[MSFT]
- Re: ODBC connection strings - "ODBC;" prefix?
- From: Dave Calkins
- Re: ODBC connection strings - "ODBC;" prefix?
- Prev by Date: Re: CRecordset dont get correct value
- Next by Date: Re: ODBC connection strings - "ODBC;" prefix?
- Previous by thread: Re: ODBC connection strings - "ODBC;" prefix?
- Next by thread: Re: ODBC connection strings - "ODBC;" prefix?
- Index(es):
Relevant Pages
|
Loading