|
|||||||||
|
Crystal Reports Tools: Improve Performance While Saving Time and Money |
|
Crystal Reports: COM Data SourcesCOM data sources: gateways to data in your legacy systems. This is really information for developers, but users can gain insight from it as well. These COM data sources have been available for a couple of versions now and we are only just discovering how useful they can be. A COM data source is an ADO record set created by a VB program. You then use this as the source of data for your report. The Visual Basic code is as simple as:
So, where can you use one? Anywhere your data are not stored in a convenient database, but can be retrieved using Visual Basic. We have read of suggestions of using one to retrieve some legacy data from another system, or reading a text file. If you can write some Visual Basic code to see the data and present them to a user, then you can wrap the function code above around your code, and compile it into a DLL. Register the DLL and use that to send your data to your Crystal Report. Now, here's something very interesting to end-users, Crystal Report writers, and Crystal Report admins. A COM data driver is the key to our cViewIMAGE utility. cViewIMAGE is a COM data driver that can reference an image file in a field and return the embedded image to use in your report. This is an excellent way to raise the perceived value of any report and increase your own job security! Click here for an example of how to include a single image in a report. See below for a Microsoft table that shows data types used in COM. The source for this is http://msdn.microsoft.com/en-us/library/sak564ww.aspx
This article is copyrighted by Crystalkeen, Mindconnection, and Chelsea Technologies Ltd. It may be freely copied and distributed as long as the original copyright is displayed and no modifications are made to this material. Extracts are permitted. The names Crystal Reports and Seagate Info are trademarks owned by Business Objects. |
The following table shows data types used in COM and their corresponding .NET Framework built-in value types or classes. Any type not explicitly identified in this table is converted to an Int32 system type. For corresponding types in Visual Basic 2005, C#, and C++, see the Introduction to the .NET Framework Class Library.
| COM value type | COM reference type | System type |
|---|---|---|
|
bool |
bool * |
|
|
char, small |
char *, small * |
|
|
short |
short * |
|
|
long, int |
long *, int * |
|
|
Hyper |
hyper * |
|
|
unsigned char, byte |
unsigned char *, byte * |
|
|
wchar_t, unsigned short |
wchar_t *, unsigned short * |
|
|
unsigned long, unsigned int |
unsigned long *, unsigned int * |
|
|
unsigned hyper |
unsigned hyper * |
|
|
float |
float * |
|
|
double |
double * |
|
|
VARIANT_BOOL |
VARIANT_BOOL * |
|
|
void * |
void ** |
|
|
HRESULT |
HRESULT * |
System.Int16 orSystem.IntPtr |
|
SCODE |
SCODE * |
System.Int32 |
|
BSTR |
BSTR * |
|
|
LPSTR or [string, …] char * |
LPSTR * |
System.String |
|
LPWSTR or [string, …] wchar_t * |
LPWSTR * |
System.String |
|
VARIANT |
VARIANT * |
|
|
DECIMAL |
DECIMAL * |
|
|
DATE |
DATE * |
|
|
GUID |
GUID * |
|
|
CURRENCY |
CURRENCY * |
|
|
IUnknown * |
IUnknown ** |
System.Object |
|
IDispatch * |
IDispatch ** |
System.Object |
|
SAFEARRAY(type) |
SAFEARRAY(type) * |
type[] |
The following table lists COM value and reference types that convert to corresponding element types. For example, a COM coclass automatically maps to a managed class with the same name.
| COM value type | COM reference type | Element type |
|---|---|---|
|
Typedef BaseType MyType |
ByRef BaseType |
BaseType |
|
MyStruct |
ByRef VALUETYPE<MyStruct> |
valuetype<MyStruct> |
|
MyEnum |
ByRef VALUETYPE<MyEnum> |
valuetype<MyEnum> |
|
MyInterface * |
ByRef CLASS <MyInterface> |
Class <MyInterface> |
|
MyCoClass |
ByRef CLASS <_Class> |
Class <_Class> |