v2: Fixed test.
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/msado15/recordset.c | 43 ++++++++++++++++++++++++++++++++++++ dlls/msado15/tests/msado15.c | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c index e830f66e1ba..12bb9680258 100644 --- a/dlls/msado15/recordset.c +++ b/dlls/msado15/recordset.c @@ -721,6 +721,46 @@ static const ISupportErrorInfoVtbl fields_supporterrorinfo_vtbl = fields_supporterrorinfo_InterfaceSupportsErrorInfo };
+static void map_rowset_fields(struct recordset *recordset, struct fields *fields) +{ + HRESULT hr; + IColumnsInfo *columninfo; + DBORDINAL columns, i; + DBCOLUMNINFO *colinfo; + OLECHAR *stringsbuffer; + + /* Not Finding the interface or GetColumnInfo failing just causes 0 Fields to be returned */ + hr = IRowset_QueryInterface(recordset->row_set, &IID_IColumnsInfo, (void**)&columninfo); + if (FAILED(hr)) + return; + + hr = IColumnsInfo_GetColumnInfo(columninfo, &columns, &colinfo, &stringsbuffer); + if (SUCCEEDED(hr)) + { + for (i=0; i < columns; i++) + { + TRACE("Adding Column %lu, pwszName: %s, pTypeInfo %p, iOrdinal %lu, dwFlags 0x%08x, " + "ulColumnSize %lu, wType %d, bPrecision %d, bScale %d\n", + i, debugstr_w(colinfo[i].pwszName), colinfo[i].pTypeInfo, colinfo[i].iOrdinal, + colinfo[i].dwFlags, colinfo[i].ulColumnSize, colinfo[i].wType, + colinfo[i].bPrecision, colinfo[i].bScale); + + hr = append_field(fields, colinfo[i].pwszName, colinfo[i].wType, colinfo[i].ulColumnSize, + colinfo[i].dwFlags, NULL); + if (FAILED(hr)) + { + ERR("Failed to add Field name - 0x%08x\n", hr); + return; + } + } + + CoTaskMemFree(colinfo); + CoTaskMemFree(stringsbuffer); + } + + IColumnsInfo_Release(columninfo); +} + static HRESULT fields_create( struct recordset *recordset, struct fields **ret ) { struct fields *fields; @@ -732,6 +772,9 @@ static HRESULT fields_create( struct recordset *recordset, struct fields **ret ) fields->recordset = recordset; _Recordset_AddRef( &fields->recordset->Recordset_iface );
+ if ( recordset->row_set ) + map_rowset_fields(recordset, fields); + *ret = fields; TRACE( "returning %p\n", *ret ); return S_OK; diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index 50418690613..bc9b4a24761 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -596,7 +596,7 @@ static void test_ADORecordsetConstruction(void)
count = -1; hr = Fields_get_Count( fields, &count ); - todo_wine ok( count == 1, "got %d\n", count ); + ok( count == 1, "got %d\n", count ); if (count > 0) { VARIANT index;