Bug #36293 SQLDriverConnect does not return SQL_NO_DATA on cancel
Submitted: 23 Apr 2008 14:49 Modified: 7 Jul 2008 17:15
Reporter: Michel Boto Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1.4r1107 OS:Any
Assigned to: Jim Winstead CPU Architecture:Any

[23 Apr 2008 14:49] Michel Boto
Description:
Per ODBC docs this method should return SQL_NO_DATA when the user cancels the dialog to connect.  MyODBC, however, returns SQL_ERROR.

The offending lines are these:

------ driver/connect.c lines 683-688 ----------

    if (!pFunc(hwnd, prompt_instr, fDriverCompletion,
               szConnStrOut, cbConnStrOutMax, pcbConnStrOut))
    {
      set_dbc_error(hdbc, "HY000", "User cancelled.", 0);
      rc= SQL_ERROR;
      goto error;
    }

-----------------------------------------

How to repeat:
Call SQLDriverConnect from an application, wait for it to bring up the MySQL connection dialog, and hit cancel.  The return code from the call is SQL_ERROR even though no error has been committed.

Suggested fix:
Just change the line to "rc = SQL_NO_DATA" to behave like all other ODBC drivers
[23 Apr 2008 15:06] Tonci Grgin
Hi Michel and thanks for your report.

Verified as described by looking into latest sources:

http://msdn2.microsoft.com/en-us/library/ms715433(VS.85).aspx clearly states:
If the user cancels a dialog box presented by the Driver Manager or the driver, SQLDriverConnect returns SQL_NO_DATA.
[14 May 2008 0:22] Jim Winstead
Return correct value

Attachment: bug36293.diff (text/plain), 930 bytes.

[12 Jun 2008 18:18] Lawrenty Novitsky
approved
[12 Jun 2008 18:41] Jim Winstead
The fix for this bug has been committed, and will be included in 5.1.5.
[7 Jul 2008 17:15] Tony Bedford
An entry has been added to the 5.1.5 Changelog:

SQLDriverConnect does not return SQL_NO_DATA on cancel. The ODBC documentation specifies that this method should return SQL_NO_DATA when the user cancels the dialog to connect. The connector, however, returns SQL_ERROR.