Custom Provider Crystal Asking for wrong Table

johanso2_at_msu.edu
Date: 12/12/04


Date: 11 Dec 2004 16:33:06 -0800

I'm writing my own OLE DB provider for use in Crystal Reports and other
type of reporting tools. If I connect to my OLE DB Provider in Visual
Studio it shows the schema correctly. In Crystal when you add a table
to a report; Crystal makes a call back into my provider for the columns
but it always passes in the name of the first table in my schema as
part of the restrictions instead of the table selected. Is there
something I'm not telling Crystal to uniquely find my tables or maybe
I'm not understanding the restrictions enough?

Here is how I fill out the table rowset which is basically looping
through the DataTables in a dataset and adding them to the rowset.

HRESULT CTableSchemaRowset::Execute(LONG* pcRowsAffected, ULONG, const
VARIANT*)
{
DataSet* schema =
DataSourceFactory::GetFactory()->GetDataSource()->GetSchemaDataSet();

for(int i = 0; i < schema->Tables->Count; i++)
{
System::String* tablename =
schema->Tables->get_Item(i)->get_TableName();

System::IntPtr i_ptr =
System::Runtime::InteropServices::Marshal::StringToBSTR(tablename);
BSTR bstr_tablename = static_cast<BSTR>(static_cast<void*>(i_ptr));

CTABLESRow rowData;

lstrcpyW(rowData.m_szType, OLESTR("TABLE"));
lstrcpyW(rowData.m_szTable, bstr_tablename);

m_rgRowData.Add(rowData);
(*pcRowsAffected)++;
}

return S_OK;
}

Now in the column rowset I pull the table name out of the restrictions
and then look in that Schema DataSet and look for the DataTable
matching that table and return the columns for that table.

HRESULT CColumnSchemaRowset::Execute(LONG* pcRowsAffected, ULONG
cRestrictions, const VARIANT* rgRestrictions)
{
HRESULT hr = S_OK;
DataSetConversionUtils utils;

DataSet* schema =
DataSourceFactory::GetFactory()->GetDataSource()->GetSchemaDataSet();

long restrictions = cRestrictions;

BSTR tablename = rgRestrictions[DBKIND_NAME].bstrVal;

DataTable *table = schema->Tables->get_Item(tablename);

for (ULONG iCol = 0; iCol < table->Columns->get_Count(); iCol++)
{
DataColumn *column = table->Columns->get_Item(iCol);
CCOLUMNSRow crData;
utils.ConvertDataColumnToCOLUMNSRow(column, crData);

m_rgRowData.Add(crData);
(*pcRowsAffected)++;
}

        return hr;
}

Any help would be greatly appreciated!

Norm



Relevant Pages

  • Re: Custom Provider Crystal Asking for wrong Table
    ... Try setting the restriction in RowsetViewer and see if your provider ... > Try calling IDBSchemaRowset using the OLE DB Rowset Viewer. ... >> Studio it shows the schema correctly. ...
    (microsoft.public.data.oledb)
  • Re: delete sql syntax for linked notes table
    ... Invalid use of schema and/or catalog for OLE DB provider 'MSDASQL'. ...
    (comp.databases.ms-sqlserver)
  • Linked Server (Informix) - Insert Into
    ... It reports error. ... OLE DB provider 'MSDASQL' reported an error. ...
    (microsoft.public.sqlserver.security)
  • Re: SBS R2 Premium - Monitoring & Reports Broken.
    ... Error occured attempting to retrieve task account information. ... ISA is 100% and up to date for Vista. ... It has been a while since the setup for reports has been done. ... This provider will be run using the LocalSystem ...
    (microsoft.public.windows.server.sbs)
  • Re: SBS R2 Premium - Monitoring & Reports Broken.
    ... Les Connor [SBS MVP] ... It has been a while since the setup for reports has been done. ... This provider will be run using the LocalSystem ... This account is privileged and the provider may cause a security ...
    (microsoft.public.windows.server.sbs)