On 2/19/21 11:58 AM, Alistair Leslie-Hughes wrote:
+ hr = ADOConnectionConstruction15_get_Session(construct, &session); + ADOConnectionConstruction15_Release(construct); + if (FAILED(hr)) + return E_FAIL; + + hr = IUnknown_QueryInterface(session, &IID_IOpenRowset, (void**)&openrowset); + if (FAILED(hr)) return hr; + + hr = IOpenRowset_QueryInterface(openrowset, &IID_IDBCreateCommand, (void**)&create_command); + if (FAILED(hr)) + goto done; + + hr = IDBCreateCommand_CreateCommand(create_command, NULL, &IID_IUnknown, (IUnknown **)&cmd); + if (FAILED(hr)) + goto done; + + hr = ICommand_QueryInterface(cmd, &IID_ICommandText, (void**)&command_text); + if (FAILED(hr)) + { + FIXME("Currently only ICommandText interface is support\n"); + goto done; + } + + hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, V_BSTR(&source)); + if (FAILED(hr)) + goto done; + + hr = ICommandText_Execute(command_text, NULL, &IID_IUnknown, NULL, &affected, &rowset); + if (FAILED(hr)) + goto done; Most of that could use same pattern as get_Session(), so you don't have to use a block of releases in 'done'.
Is it safe to assume that 'source' is VT_BSTR?