Fix compilation errors for the ODBC2.50 driver.
authorHiroshi Inoue <inoue@tpf.co.jp>
Wed, 14 May 2003 23:45:54 +0000 (23:45 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Wed, 14 May 2003 23:45:54 +0000 (23:45 +0000)
dlg_wingui.c
setup.c

index d4b53983626ed2470151bebd81e445743be1278a..ca7666d15008f1fa674656a8f6b34f4d2b348dfc 100644 (file)
@@ -564,15 +564,10 @@ makeDriversList(HWND lwnd, const ConnInfo *ci)
 
    hmodule = GetModuleHandle("ODBC32");
    if (!hmodule)   return lcount;
-   addr = GetProcAddress(hmodule, "SQLAllocHandle");
+   addr = GetProcAddress(hmodule, "SQLAllocEnv");
    if (!addr)  return lcount;
-   ret = (*addr)(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
-   if (SQL_SUCCESS == ret)
-   {
-       addr = GetProcAddress(hmodule, "SQLSetEnvAttr");
-       if (addr)
-           ret = (*addr)(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, 0);
-   } 
+   ret = (*addr)(&henv);
+   if (SQL_SUCCESS != ret) return lcount;
    do
    {
        ret = SQLDrivers(henv, direction,
@@ -591,9 +586,9 @@ makeDriversList(HWND lwnd, const ConnInfo *ci)
        }
        direction = SQL_FETCH_NEXT;
    } while (1);
-   addr = GetProcAddress(hmodule, "SQLFreeHandle");
+   addr = GetProcAddress(hmodule, "SQLFreeEnv");
    if (addr)
-       (*addr)(SQL_HANDLE_ENV, henv);
+       (*addr)(henv);
 
    return lcount;
 }
diff --git a/setup.c b/setup.c
index c288e17f4e8556b5ae3d4a5ec9d5f90c9c1f05ed..70d63d7aab01fa7cb5ae260efc8c6381ff4f1f95 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -395,15 +395,18 @@ SetDSNAttributes(HWND hwndParent, LPSETUPDLG lpsetupdlg, DWORD *errcode)
    /* Write the data source name */
    if (!SQLWriteDSNToIni(lpszDSN, lpsetupdlg->lpszDrvr))
    {
-       DWORD   err;
+       RETCODE ret = SQL_ERROR;
+       DWORD   err = SQL_ERROR;
        char    szMsg[SQL_MAX_MESSAGE_LENGTH];
 
-       SQLInstallerError(1, &err, szMsg, sizeof(szMsg), NULL);
+#if (ODBCVER >= 0x0300)
+       ret = SQLInstallerError(1, &err, szMsg, sizeof(szMsg), NULL);
+#endif /* ODBCVER */
        if (hwndParent)
        {
            char        szBuf[MAXPGPATH];
 
-           if (SQL_SUCCESS != err)
+           if (SQL_SUCCESS != ret)
            {
                LoadString(s_hModule, IDS_BADDSN, szBuf, sizeof(szBuf));
                wsprintf(szMsg, szBuf, lpszDSN);
@@ -437,11 +440,11 @@ ChangeDriverName(HWND hwndParent, LPSETUPDLG lpsetupdlg, LPCSTR driver_name)
 
    if (!ci->dsn[0])
    {
-       err = ODBC_ERROR_INVALID_DSN;
+       err = IDS_BADDSN;
    }
    else if (!driver_name || strnicmp(driver_name, "postgresql", 10))
    {
-       err = ODBC_ERROR_INVALID_NAME;
+       err = IDS_BADDSN;
    }
    else
    {
@@ -451,7 +454,7 @@ ChangeDriverName(HWND hwndParent, LPSETUPDLG lpsetupdlg, LPCSTR driver_name)
        if (!SetDSNAttributes(hwndParent, lpsetupdlg, &err))
        {
            if (!err)
-               err = ODBC_ERROR_INVALID_DSN;
+               err = IDS_BADDSN;
            lpsetupdlg->lpszDrvr = lpszDrvr;
        }
    }