From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/msdasql/Makefile.in | 2 +- dlls/msdasql/msdasql_main.c | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/dlls/msdasql/Makefile.in b/dlls/msdasql/Makefile.in index 0f5453131f6..01670b308ba 100644 --- a/dlls/msdasql/Makefile.in +++ b/dlls/msdasql/Makefile.in @@ -1,5 +1,5 @@ MODULE = msdasql.dll -IMPORTS = uuid ole32 oleaut32 odbc32 +IMPORTS = uuid ole32 oleaut32 odbc32 user32
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/msdasql/msdasql_main.c b/dlls/msdasql/msdasql_main.c index 017a2517a72..9d8c74cc367 100644 --- a/dlls/msdasql/msdasql_main.c +++ b/dlls/msdasql/msdasql_main.c @@ -530,26 +530,32 @@ 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] = {0}, *p = connection, outstr[1024];
FIXME("%p semi-stub\n", provider);
- for(i=0; i < sizeof(provider->properties); i++) + 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 = wsprintfW(p, 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 = wsprintfW(p, 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);