Module: wine Branch: master Commit: a40d67e04a23b9034c57ebccbb6231d90cc09b7b URL: https://gitlab.winehq.org/wine/wine/-/commit/a40d67e04a23b9034c57ebccbb6231d...
Author: Alistair Leslie-Hughes leslie_alistair@hotmail.com Date: Wed Feb 8 17:19:32 2023 +1100
msdasql: Use SQLDriverConnectW to connect to the ODBC driver.
---
dlls/msdasql/msdasql_main.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/dlls/msdasql/msdasql_main.c b/dlls/msdasql/msdasql_main.c index 017a2517a72..2f25498abca 100644 --- a/dlls/msdasql/msdasql_main.c +++ b/dlls/msdasql/msdasql_main.c @@ -530,26 +530,35 @@ static ULONG WINAPI dbinit_Release(IDBInitialize *iface) static HRESULT WINAPI dbinit_Initialize(IDBInitialize *iface) { struct msdasql *provider = impl_from_IDBInitialize(iface); - int i; + int i, len; SQLRETURN ret; + WCHAR connection[1024], *p = connection, outstr[1024];
FIXME("%p semi-stub\n", provider);
- for(i=0; i < sizeof(provider->properties); i++) + *p = 0; + for(i=0; i < ARRAY_SIZE(provider->properties); i++) { if (provider->properties[i].id == DBPROP_INIT_DATASOURCE) - break; - } - - if (i >= sizeof(provider->properties)) - { - ERR("Datasource not found\n"); - return E_FAIL; + { + len = swprintf(p, ARRAY_SIZE(connection) - (p - connection), + L"DSN=%s;", V_BSTR(&provider->properties[i].value)); + p+= len; + } + else if (provider->properties[i].id == DBPROP_INIT_PROVIDERSTRING) + { + if (V_VT(&provider->properties[i].value) == VT_BSTR && SysStringLen(V_BSTR(&provider->properties[i].value)) ) + { + len = swprintf(p, ARRAY_SIZE(connection) - (p - connection), + L"%s;", V_BSTR(&provider->properties[i].value)); + p+= len; + } + } }
- ret = SQLConnectW( provider->hdbc, (SQLWCHAR *)V_BSTR(&provider->properties[i].value), - SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS ); - TRACE("SQLConnectW ret %d\n", ret); + ret = SQLDriverConnectW( provider->hdbc, NULL, connection, wcslen(connection), + outstr, ARRAY_SIZE(outstr), NULL, 0); + TRACE("SQLDriverConnectW ret %d\n", ret); if (ret != SQL_SUCCESS) { dump_sql_diag_records(SQL_HANDLE_DBC, provider->hdbc);