-- v3: msdasql: Use SQLDriverConnectW to connect to the ODBC driver include: Add missing SQL prototype.
From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- include/sqlucode.h | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/include/sqlucode.h b/include/sqlucode.h index f1eaace87c1..a4721b04208 100644 --- a/include/sqlucode.h +++ b/include/sqlucode.h @@ -32,6 +32,9 @@ extern "C" { #define SQL_WVARCHAR (-9) #define SQL_WLONGVARCHAR (-10)
+SQLRETURN WINAPI SQLColAttributesW(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, + SQLPOINTER rgbDesc, SQLSMALLINT cbDescMax, SQLSMALLINT *pcbDesc, SQLLEN *pfDesc); + SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle, SQLWCHAR *ServerName, SQLSMALLINT NameLength1, SQLWCHAR *UserName, SQLSMALLINT NameLength2, @@ -43,6 +46,11 @@ SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle, SQLSMALLINT *DataType, SQLULEN *ColumnSize, SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable);
+SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, + SQLHWND WindowHandle, WCHAR *InConnectionString, + SQLSMALLINT Length, WCHAR *OutConnectionString, SQLSMALLINT BufferLength, + SQLSMALLINT *Length2, SQLUSMALLINT DriverCompletion); + SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle, SQLWCHAR *StatementText, SQLINTEGER TextLength);
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);