Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal report and visual c

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
how i can connect crystal reports and visual c?
plz if any one have any snip of code, or any hint kindly reply me

Thanks
 
Hi!

I've worked with Crystal Reports in the past. I cannot remember source code which I wrote but I can give you the guide lines:

1. You should use COM to manipulate Crystal Reports.
2. Go in Crystal Reports folders and search all files with .TLB or .OCX extension and with Ole Object Viewer Tool open them to see the type info (the IDL file)
3. Make a Visual C++ project (you don't have to use MFC)
4. Import all COM servers you want from Crystal Reports:
Code:
#import "Crystl32.tlb" no_implementation rename_namespace("CRPE")
in your stdafx.h file, and
Code:
#import "Crystl32.tlb" implementation_only  rename_namespace("CRPE")
in the file with WinMain.

5. In WinMain make
Code:
CoInitialize()
at the beginning and
Code:
CoUninitialize()
to the end.

6. Declare smart-pointers for usefull Crystal Reports COM objects (I remember the Application object). You can inspect the associated .TLH file in Debug folder to find helpful information.

E.g.:
Code:
try
{
 CRPE::_Application spCrpeApp;
 hr = spCrpeApp.CreateInstance(__uuidof(CRPE::Application));
 if(FAILED(hr))
     _com_issue_error(hr);
 spCrpeApp->Login(    ...      );
}
catch(_com_error e)
{
 _bstr_t str = e.Description()
 if(str.length() == 0)
   str = e.ErrorMessage();
}
[code]
GookLuck!

Marius Samoila
Brainbench MVP for Visual C++
[URL unfurl="true"]http://www.brainbench.com[/URL]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top