--- description: "Learn more about: Fetching Data" title: "Fetching Data" ms.date: "10/19/2018" helpviewer_keywords: ["data [C++], fetching", "rowsets [C++], fetching", "fetching", "OLE DB consumer templates [C++], fetching data"] ms.assetid: b07f747f-9855-4f27-a03d-b1d5b10fa284 --- # Fetching Data After you open the data source, session, and rowset objects, you can fetch data. Depending on the type of accessor you're using, you might need to bind columns. ## To fetch data 1. Open the rowset using the appropriate **Open** command. 1. If you're using `CManualAccessor`, bind the output columns if you haven't already done so. The following example is taken from the [DBViewer](https://github.com/Microsoft/VCSamples/tree/master/VC2008Samples/ATL/OLEDB/Consumer/dbviewer) sample. To bind the columns, call `GetColumnInfo`, and then create an accessor with the bindings, as shown in the following example: ```cpp // From the DBViewer Sample CDBTreeView::OnQueryEdit // Get the column information ULONG ulColumns = 0; DBCOLUMNINFO* pColumnInfo = NULL; LPOLESTR pStrings = NULL; if (rs.GetColumnInfo(&ulColumns, &pColumnInfo, &pStrings) != S_OK) ThrowMyOLEDBException(rs.m_pRowset, IID_IColumnsInfo); struct MYBIND* pBind = new MYBIND[ulColumns]; rs.CreateAccessor(ulColumns, &pBind[0], sizeof(MYBIND)*ulColumns); for (ULONG l=0; l