Re: ODBC connection strings - "ODBC;" prefix?



Hi, David,
Thanks for your response.

From my test, I found that this issue should be caused by SQLDriverConnect
which 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.
======================================================





.



Relevant Pages

  • Re: ODBC connection strings - "ODBC;" prefix?
    ... Thanks for your response. ... MFC is adding the "ODBC;" in the call I referenced in my prior reply. ... As you can see, if there is "ODBC;" in the connection string, ... Microsoft Online Community Support ...
    (microsoft.public.vc.database)
  • Re: Create OdbcConnection with a DSN onlt?
    ... you can use DSN to connect it in connectionstring. ... Here is the knowledge base article introduce how to use .NET managed ODBC ... Microsoft MSDN Online Support Lead ... nature are best handled working with a dedicated Microsoft Support Engineer ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: ODBC connection strings - "ODBC;" prefix?
    ... Now let us look back to your code snippet attached in your first thread: ... string for printing and letting you know that it is an ODBC connection. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vc.database)
  • Re: How to load data in ListBox using one command from ADODB Recor
    ... Simply use an DSN-less connection string as the ODBC Connection String. ... >> Is there something unique about how you use the ADODB recordset? ... >>> I am using ADODB recordset and has SQL server database. ...
    (microsoft.public.access.gettingstarted)
  • RE: ODBC connection strings - "ODBC;" prefix?
    ... I understand that you found that "ODBC;" prefix could not work with Oracle ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vc.database)

Loading