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



In summary, the official Microsoft position is that the strange
behavior that causes the operation to fail when applied seemingly
according to all the rules is " a by design behavior for upward
compatibility and should not be a bug".

On Mon, 12 Mar 2007 10:40:23 -0400, "Dave Calkins"
<david.calkins@xxxxxxxxxxxxxxx> wrote:

Thanks for your response. It sounds like CDatabase::Open() is working
correctly by removing the "ODBC;" if present and that CDatabase::OpenEx() is
not working correctly since it does not remove that.

Secondly, I don't think you're understanding what I'm saying. I am NOT
adding "ODBC;" to the string. MFC is doing that for me. You're talking
about it as though I'm adding it.

MFC is adding the "ODBC;" in the call I referenced in my prior reply. And
when I call CDatabase::OpenEx() it is not removing it.

So, I guess the way to go is to use Open() not OpenEx(). I'll proceed with
that. However, usually when there's a method and an Ex method, you're
supposed to use the Ex (I thought). I think OpenEx should also remove the
"ODBC;" if present. Just my $0.02.

Thanks,
Dave


"Charles Wang[MSFT]" <changliw@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:BcTFJKLZHHA.4088@xxxxxxxxxxxxxxxxxxxxxxxxx
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 ERROR
    ... analysis might be the efficient method to find clues. ... open a Support incident with Microsoft Product Support Services so that a ... For a complete list of Microsoft Product Support Services phone numbers, ... Microsoft OLE DB Provider for ODBC Drivers ...
    (microsoft.public.sqlserver.odbc)
  • Re: To get row in XML
    ... I think that you can use ADO or ODBC to execute the query "select * from ... Thanks for using Microsoft Managed Newsgroup. ... Microsoft Online Community Support ...
    (microsoft.public.data.oledb)
  • Re: ODBC connection strings - "ODBC;" prefix?
    ... As you can see, if there is "ODBC;" in the connection string, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vc.database)
  • 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: ODBC connection strings - "ODBC;" prefix?
    ... As I indicated in my post, the prefix is actually added in the ... the "ODBC;" prefix is indeed no need for OpenEx. ... MFC will change it to a valid connection string without ... Microsoft Online Community Support ...
    (microsoft.public.vc.database)

Quantcast