From d2d82abfba3d43d4416f14ac5318acd4eab8528c Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Mon, 5 May 2025 10:17:22 +1000 Subject: [PATCH] odbc32: SQLGetData handle ANSI driver --- dlls/odbc32/proxyodbc.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index a94b31cc544..78ec2683e63 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -2592,8 +2592,11 @@ static SQLRETURN get_data_unix( struct statement *stmt, SQLUSMALLINT column, SQL static SQLRETURN get_data_win32( struct statement *stmt, SQLUSMALLINT column, SQLSMALLINT type, SQLPOINTER value, SQLLEN buflen, SQLLEN *retlen ) { + SQLRETURN ret = SQL_ERROR; + if (stmt->hdr.win32_funcs->SQLGetData) { + BOOL wants_wchar = FALSE; struct environment *env = (struct environment *)find_object_type(SQL_HANDLE_ENV, stmt->hdr.parent); if (env && env->driver_ver == SQL_OV_ODBC2) { @@ -2605,10 +2608,29 @@ static SQLRETURN get_data_win32( struct statement *stmt, SQLUSMALLINT column, SQ type = SQL_C_TIMESTAMP; } - return stmt->hdr.win32_funcs->SQLGetData( stmt->hdr.win32_handle, column, type, value, buflen, retlen ); + if ( driver_ansi_only(stmt->hdr.win32_funcs) ) + { + if (type == SQL_C_WCHAR) + { + type = SQL_CHAR; + wants_wchar = TRUE; + } + } + + ret = stmt->hdr.win32_funcs->SQLGetData( stmt->hdr.win32_handle, column, type, value, buflen, retlen ); + + if (SUCCESS(ret) && wants_wchar ) + { + WCHAR *str = strnAtoW(value, -1); + wcscpy(value, str); + free(str); + + if (retlen) + *retlen = *retlen * sizeof(WCHAR); + } } - return SQL_ERROR; + return ret; } /************************************************************************* -- 2.50.1