From: Piotr Caban piotr@codeweavers.com
--- dlls/msado15/recordset.c | 1 + dlls/msado15/tests/msado15.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c index 66309407268..d86b33296fe 100644 --- a/dlls/msado15/recordset.c +++ b/dlls/msado15/recordset.c @@ -1398,6 +1398,7 @@ static HRESULT WINAPI recordset_get_ActiveConnection( _Recordset *iface, VARIANT { struct recordset *recordset = impl_from_Recordset( iface ); TRACE( "%p, %p\n", iface, connection ); + VariantInit( &connection ); return VariantCopy(connection, &recordset->active_connection); }
diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index b7134ee4986..3219755916c 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -265,7 +265,8 @@ if (0) hr = _Recordset_get_ActiveConnection( recordset, NULL ); }
- VariantInit(&active); + V_VT(&active) = VT_UNKNOWN; + V_UNKNOWN(&active) = (IUnknown *)0xdeadbeef; hr = _Recordset_get_ActiveConnection( recordset, &active ); ok( hr == S_OK, "got %08lx\n", hr ); ok( V_VT(&active) == VT_DISPATCH, "got %d\n", V_VT(&active) );
From: Piotr Caban piotr@codeweavers.com
--- dlls/msado15/recordset.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c index d86b33296fe..dae609a0d7c 100644 --- a/dlls/msado15/recordset.c +++ b/dlls/msado15/recordset.c @@ -48,7 +48,7 @@ struct recordset ADORecordsetConstruction ADORecordsetConstruction_iface; ISupportErrorInfo ISupportErrorInfo_iface; LONG refs; - VARIANT active_connection; + _Connection *active_connection; LONG state; struct fields fields; LONG count; @@ -1397,9 +1397,13 @@ static HRESULT WINAPI recordset_put_ActiveConnection( _Recordset *iface, VARIANT static HRESULT WINAPI recordset_get_ActiveConnection( _Recordset *iface, VARIANT *connection ) { struct recordset *recordset = impl_from_Recordset( iface ); + TRACE( "%p, %p\n", iface, connection ); - VariantInit( &connection ); - return VariantCopy(connection, &recordset->active_connection); + + V_VT(connection) = VT_DISPATCH; + V_DISPATCH(connection) = (IDispatch *)recordset->active_connection; + if (recordset->active_connection) _Connection_AddRef( recordset->active_connection ); + return S_OK; }
static HRESULT WINAPI recordset_get_BOF( _Recordset *iface, VARIANT_BOOL *bof ) @@ -1595,7 +1599,7 @@ static HRESULT WINAPI recordset_CancelUpdate( _Recordset *iface )
FIXME( "%p\n", iface );
- if (V_DISPATCH(&recordset->active_connection) == NULL) + if (recordset->active_connection == NULL) return S_OK;
recordset->editmode = adEditNone; @@ -2049,6 +2053,7 @@ static HRESULT WINAPI recordset_Open( _Recordset *iface, VARIANT source, VARIANT HRESULT hr; DBBINDING *bindings; DBBYTEOFFSET datasize; + _Connection *conn;
TRACE( "%p, %s, %s, %d, %d, %ld\n", recordset, debugstr_variant(&source), debugstr_variant(&active_connection), cursor_type, lock_type, options ); @@ -2076,9 +2081,15 @@ static HRESULT WINAPI recordset_Open( _Recordset *iface, VARIANT source, VARIANT if (FAILED(hr)) return E_FAIL;
- hr = VariantCopy(&recordset->active_connection, &active_connection); + hr = IDispatch_QueryInterface( V_DISPATCH(&active_connection), &IID__Connection, (void**)&conn ); if (FAILED(hr)) - return E_FAIL; + { + IUnknown_Release(session); + return hr; + } + + if (recordset->active_connection) _Connection_Release( recordset->active_connection ); + recordset->active_connection = conn;
if (V_VT(&source) != VT_BSTR) { @@ -2152,7 +2163,7 @@ static HRESULT WINAPI recordset_Update( _Recordset *iface, VARIANT fields, VARIA
FIXME( "%p, %s, %s\n", iface, debugstr_variant(&fields), debugstr_variant(&values) );
- if (V_DISPATCH(&recordset->active_connection) == NULL) + if (recordset->active_connection == NULL) return S_OK;
recordset->editmode = adEditNone; @@ -2276,7 +2287,7 @@ static HRESULT WINAPI recordset_UpdateBatch( _Recordset *iface, AffectEnum affec
FIXME( "%p, %u\n", iface, affect_records );
- if (V_DISPATCH(&recordset->active_connection) == NULL) + if (recordset->active_connection == NULL) return S_OK;
recordset->editmode = adEditNone; @@ -2289,7 +2300,7 @@ static HRESULT WINAPI recordset_CancelBatch( _Recordset *iface, AffectEnum affec
FIXME( "%p, %u\n", iface, affect_records );
- if (V_DISPATCH(&recordset->active_connection) == NULL) + if (recordset->active_connection == NULL) return S_OK;
recordset->editmode = adEditNone; @@ -2371,7 +2382,7 @@ static HRESULT WINAPI recordset_Cancel( _Recordset *iface )
FIXME( "%p\n", iface );
- if (V_DISPATCH(&recordset->active_connection) == NULL) + if (recordset->active_connection == NULL) return S_OK;
recordset->editmode = adEditNone; @@ -2770,8 +2781,7 @@ HRESULT Recordset_create( void **obj ) recordset->Recordset_iface.lpVtbl = &recordset_vtbl; recordset->ISupportErrorInfo_iface.lpVtbl = &recordset_supporterrorinfo_vtbl; recordset->ADORecordsetConstruction_iface.lpVtbl = &rsconstruction_vtbl; - V_VT(&recordset->active_connection) = VT_DISPATCH; - V_DISPATCH(&recordset->active_connection) = NULL; + recordset->active_connection = NULL; recordset->refs = 1; recordset->index = -1; recordset->cursor_location = adUseServer;
From: Piotr Caban piotr@codeweavers.com
--- dlls/msado15/recordset.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c index dae609a0d7c..2835ba30672 100644 --- a/dlls/msado15/recordset.c +++ b/dlls/msado15/recordset.c @@ -1384,8 +1384,11 @@ static HRESULT WINAPI recordset_put_AbsolutePosition( _Recordset *iface, Positio
static HRESULT WINAPI recordset_putref_ActiveConnection( _Recordset *iface, IDispatch *connection ) { - FIXME( "%p, %p\n", iface, connection ); - return E_NOTIMPL; + VARIANT v; + + V_VT(&v) = VT_DISPATCH; + V_DISPATCH(&v) = connection; + return _Recordset_put_ActiveConnection( iface, v ); }
static HRESULT WINAPI recordset_put_ActiveConnection( _Recordset *iface, VARIANT connection )
From: Piotr Caban piotr@codeweavers.com
--- dlls/msado15/recordset.c | 45 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c index 2835ba30672..53153bb62f2 100644 --- a/dlls/msado15/recordset.c +++ b/dlls/msado15/recordset.c @@ -1393,8 +1393,49 @@ static HRESULT WINAPI recordset_putref_ActiveConnection( _Recordset *iface, IDis
static HRESULT WINAPI recordset_put_ActiveConnection( _Recordset *iface, VARIANT connection ) { - FIXME( "%p, %s\n", iface, debugstr_variant(&connection) ); - return E_NOTIMPL; + struct recordset *recordset = impl_from_Recordset( iface ); + _Connection *conn; + LONG state; + HRESULT hr; + + TRACE( "%p, %s\n", iface, debugstr_variant(&connection) ); + + switch( V_VT(&connection) ) + { + case VT_BSTR: + hr = Connection_create( (void **)&conn ); + if (FAILED(hr)) return hr; + hr = _Connection_Open( conn, V_BSTR(&connection), NULL, NULL, adConnectUnspecified ); + if (FAILED(hr)) + { + _Connection_Release( conn ); + return hr; + } + break; + + case VT_UNKNOWN: + case VT_DISPATCH: + if (!V_UNKNOWN(&connection)) return MAKE_ADO_HRESULT( adErrInvalidConnection ); + hr = IUnknown_QueryInterface( V_UNKNOWN(&connection), &IID__Connection, (void **)&conn ); + if (FAILED(hr)) return hr; + hr = _Connection_get_State( conn, &state ); + if (SUCCEEDED(hr) && state != adStateOpen) + hr = MAKE_ADO_HRESULT( adErrInvalidConnection ); + if (FAILED(hr)) + { + _Connection_Release( conn ); + return hr; + } + break; + + default: + FIXME( "unsupported connection %s\n", debugstr_variant(&connection) ); + return E_NOTIMPL; + } + + if (recordset->active_connection) _Connection_Release( recordset->active_connection ); + recordset->active_connection = conn; + return S_OK; }
static HRESULT WINAPI recordset_get_ActiveConnection( _Recordset *iface, VARIANT *connection )
From: Piotr Caban piotr@codeweavers.com
--- dlls/msado15/recordset.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c index 53153bb62f2..b5953b31aa7 100644 --- a/dlls/msado15/recordset.c +++ b/dlls/msado15/recordset.c @@ -2097,7 +2097,6 @@ static HRESULT WINAPI recordset_Open( _Recordset *iface, VARIANT source, VARIANT HRESULT hr; DBBINDING *bindings; DBBYTEOFFSET datasize; - _Connection *conn;
TRACE( "%p, %s, %s, %d, %d, %ld\n", recordset, debugstr_variant(&source), debugstr_variant(&active_connection), cursor_type, lock_type, options ); @@ -2110,13 +2109,16 @@ static HRESULT WINAPI recordset_Open( _Recordset *iface, VARIANT source, VARIANT return S_OK; }
- if (V_VT(&active_connection) != VT_DISPATCH) + if (V_VT(&active_connection) != VT_ERROR || V_ERROR(&active_connection) != DISP_E_PARAMNOTFOUND) { - FIXME("Unsupported Active connection type %d\n", V_VT(&active_connection)); - return MAKE_ADO_HRESULT( adErrInvalidConnection ); + hr = _Recordset_put_ActiveConnection( iface, active_connection ); + if (FAILED(hr)) + return hr; } + else if (!recordset->active_connection) + return MAKE_ADO_HRESULT( adErrInvalidConnection );
- hr = IDispatch_QueryInterface(V_DISPATCH(&active_connection), &IID_ADOConnectionConstruction15, (void**)&construct); + hr = _Connection_QueryInterface(recordset->active_connection, &IID_ADOConnectionConstruction15, (void**)&construct); if (FAILED(hr)) return E_FAIL;
@@ -2125,16 +2127,6 @@ static HRESULT WINAPI recordset_Open( _Recordset *iface, VARIANT source, VARIANT if (FAILED(hr)) return E_FAIL;
- hr = IDispatch_QueryInterface( V_DISPATCH(&active_connection), &IID__Connection, (void**)&conn ); - if (FAILED(hr)) - { - IUnknown_Release(session); - return hr; - } - - if (recordset->active_connection) _Connection_Release( recordset->active_connection ); - recordset->active_connection = conn; - if (V_VT(&source) != VT_BSTR) { FIXME("Unsupported source type!\n");