This patch expects the libpath when using a named DSN (libpath is stored in registry w/DSN). Otherwise, on DSN-less connection, we expect the driver name. (the Driver field is used to lookup the setup lib for prompting). This patch always sends the *name* into the GUI dialog. This serves two purposes: * DSN-less connection is used for "Test" button and needs driver *name* * And for this to work, if we get a libname (DSN edit), we immediately get the name. Also, enable the OK+Test buttons if we're prompting (not DSN-add/edit). Index: driver/connect.c =================================================================== --- driver/connect.c (revision 1113) +++ driver/connect.c (working copy) @@ -602,14 +602,13 @@ goto error; } - /* - At this point we should have a driver name (friendly name) either - loaded from DSN or provided in connection string. So lets determine - the setup library file name (better to not assume name). We read from - ODBC system info. This allows someone configure for a custom setup - interface. - */ - sqlwcharncpy(pDriver->lib, ds->driver, ODBCDRIVER_STRLEN); + /* if given a named DSN, we will have the path in the DRIVER field */ + if (ds->name) + sqlwcharncpy(pDriver->lib, ds->driver, ODBCDRIVER_STRLEN); + /* otherwise, it's the driver name */ + else + sqlwcharncpy(pDriver->name, ds->driver, ODBCDRIVER_STRLEN); + if (driver_lookup(pDriver)) { char sz[1024]; Index: util/installer.c =================================================================== --- util/installer.c (revision 1113) +++ util/installer.c (working copy) @@ -682,20 +682,21 @@ for (used= 0; used < size; used += sqlwcharlen(entries) + 1, entries += sqlwcharlen(entries) + 1) { + int valsize; ds_map_param(ds, entries, &dest, &intdest); if ((dest || intdest) && - (size= SQLGetPrivateProfileStringW(ds->name, entries, W_EMPTY, + (valsize= SQLGetPrivateProfileStringW(ds->name, entries, W_EMPTY, val, ODBCDATASOURCE_STRLEN, W_ODBC_INI)) < 0) { rc= 1; goto end; } - else if (!size) + else if (!valsize) /* skip blanks */; else if (dest && !*dest) - ds_set_strnattr(dest, val, size); + ds_set_strnattr(dest, val, valsize); else if (intdest) *intdest= sqlwchartoul(val, NULL); @@ -806,7 +807,8 @@ attrs+= sqlwcharncat2(attrs, *strval, &attrslen); APPEND_SQLWCHAR(attrs, attrslen, delim); } - else if (intval) + /* only write out int values if they're non-zero */ + else if (intval && *intval) { attrs+= sqlwcharncat2(attrs, dsnparams[i], &attrslen); APPEND_SQLWCHAR(attrs, attrslen, '='); @@ -930,11 +932,11 @@ RESTORE_MODE(); - /* Get the actual driver name (not just file name) */ + /* Get the actual driver info (not just name) */ driver= driver_new(); - memcpy(driver->lib, ds->driver, + memcpy(driver->name, ds->driver, (sqlwcharlen(ds->driver) + 1) * sizeof(SQLWCHAR)); - if (driver_lookup_name(driver)) + if (driver_lookup(driver)) { SQLPostInstallerErrorW(ODBC_ERROR_INVALID_KEYWORD_VALUE, W_CANNOT_FIND_DRIVER); @@ -948,7 +950,7 @@ RESTORE_MODE(); /* write all fields (util method takes care of skipping blank fields) */ - if (ds_add_strprop(ds->name, W_DRIVER , ds->driver )) goto error; + if (ds_add_strprop(ds->name, W_DRIVER , driver->lib )) goto error; if (ds_add_strprop(ds->name, W_DESCRIPTION, ds->description)) goto error; if (ds_add_strprop(ds->name, W_SERVER , ds->server )) goto error; if (ds_add_strprop(ds->name, W_UID , ds->uid )) goto error; Index: setupgui/utils.c =================================================================== --- setupgui/utils.c (revision 1113) +++ setupgui/utils.c (working copy) @@ -83,7 +83,6 @@ { SQLRETURN nReturn; SQLWCHAR stringConnectIn[1024]; - Driver *driver; size_t inlen= 1024; assert(params->driver && *params->driver); @@ -98,20 +97,6 @@ } inlen-= sqlwcharlen(stringConnectIn); - /* Add driver name (not file) to connect string */ - driver= driver_new(); - memcpy(driver->lib, params->driver, - (sqlwcharlen(params->driver) + 1) * sizeof(SQLWCHAR)); - if (driver_lookup_name(driver)) - { - driver_delete(driver); - /* TODO error message */ - return SQL_ERROR; - } - sqlwcharncat2(stringConnectIn, W_DRIVER_PARAM, &inlen); - sqlwcharncat2(stringConnectIn, driver->name, &inlen); - driver_delete(driver); - if (hDBC == SQL_NULL_HDBC) { nReturn= SQLAllocHandle(SQL_HANDLE_ENV, NULL, hEnv); Index: setupgui/windows/odbcdialogparams.cpp =================================================================== --- setupgui/windows/odbcdialogparams.cpp (revision 1113) +++ setupgui/windows/odbcdialogparams.cpp (working copy) @@ -645,6 +645,13 @@ { EnableWindow(GetDlgItem(hwnd, IDC_EDIT_name), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_EDIT_description), FALSE); + /* if prompting without DSN, don't disable OK button */ + if (!pParams->name) + { + Button_Enable(GetDlgItem(hwnd,IDOK), 1); + Button_Enable(GetDlgItem(hwnd,IDC_BUTTON_TEST), 1); + RedrawWindow(hwnd,NULL,NULL,RDW_INVALIDATE); + } } BOOL b = DoCreateDialogTooltip(); @@ -687,6 +694,27 @@ pCaption= L"MySQL Connector/ODBC Data Source Configuration"; g_isPrompt= isPrompt; + /* + If prompting (with a DSN name), or not prompting (add/edit DSN), + we translate the lib path to the actual driver name. + */ + if (params->name || !isPrompt) + { + Driver *driver= driver_new(); + memcpy(driver->lib, params->driver, + (sqlwcharlen(params->driver) + 1) * sizeof(SQLWCHAR)); + if (driver_lookup_name(driver)) + { + wchar_t msg[256]; + swprintf(msg, L"Failure to lookup driver entry at path '%ls'", + driver->lib); + MessageBox(ParentWnd, msg, L"Cannot find driver entry", MB_OK); + driver_delete(driver); + return 0; + } + ds_set_strattr(¶ms->driver, driver->name); + driver_delete(driver); + } DialogBox(ghInstance, MAKEINTRESOURCE(IDD_DIALOG1), ParentWnd, (DLGPROC)FormMain_DlgProc);