Custom Provider Crystal Asking for wrong Table
johanso2_at_msu.edu
Date: 12/12/04
- Next message: Bob Beauchemin: "Re: Custom Provider Crystal Asking for wrong Table"
- Previous message: arxing: "Does ms oledb driver for sql server support IRowsetUpdate?"
- Next in thread: Bob Beauchemin: "Re: Custom Provider Crystal Asking for wrong Table"
- Reply: Bob Beauchemin: "Re: Custom Provider Crystal Asking for wrong Table"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Bob Beauchemin: "Re: Custom Provider Crystal Asking for wrong Table"
- Previous message: arxing: "Does ms oledb driver for sql server support IRowsetUpdate?"
- Next in thread: Bob Beauchemin: "Re: Custom Provider Crystal Asking for wrong Table"
- Reply: Bob Beauchemin: "Re: Custom Provider Crystal Asking for wrong Table"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|