Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PrintToPrinter gives LogOnException

Posted on 2004-11-06
5
Medium Priority
?
368 Views
Last Modified: 2007-12-19
Got a VB.NET windows application using a MsAccess database. Some of the reports (CR bundled version) have to be processed in batch mode. I use the PrintToPrinter method, it works fine on my development system but fails with a LogOnException on any other system. The same report can be perfectly previewed and printed (with interaction) by means of the CRViewer. I used the latest merge modules from crystal (BO) and set the connectionInfo for all tables (even in subreports).
What can be wrong?
0
Comment
Question by:GCCvanDorth
  • 2
  • 2
5 Comments
 

Author Comment

by:GCCvanDorth
ID: 12514165
Got it (about).

The whole stuff works if the database location in development is the same as the database location after deployment.
So if the database position will become "C:\progam files\myproject\database\mydatabase.mdb" you better create the report using this location too.
Nice? No, but at least something I can live with (as I know how my product is installed). So crystal ignores all the connectInfo somehow if you call PrintToPrinter (or ExportTo...).

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12515019
What code are you using?  It shouldn't work as you are statig so maybe there is a minor problem with the code.

mlmcc
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12517860
I think you are missing setting the location property of the tables. If you miss that crystal disregards the connection chnages . Do it this way and it will work.
This code is written in c# so if you need, convert it to vb.net
Regards
Emre

internal static void SetConnection(ref ReportDocument report, string serverName, string databaseName)
{
  try
  {
  CrystalDecisions.Shared.TableLogOnInfo MyLogonInfo;
 foreach(CrystalDecisions.CrystalReports.Engine.Table MyTable in report.Database.Tables)
   {
                   
   MyLogonInfo = MyTable.LogOnInfo;
   if (MyTable.Name == "")
   {                             MyLogonInfo.ConnectionInfo.ServerName  = serverName;
MyLogonInfo.ConnectionInfo.DatabaseName = databaseName;
MyLogonInfo.ConnectionInfo.UserID = "";
MyLogonInfo.ConnectionInfo.Password= "";                              }
else
{              
MyLogonInfo.ConnectionInfo.ServerName  = serverName;
MyLogonInfo.ConnectionInfo.DatabaseName = databaseName;
//MyLogonInfo.ConnectionInfo.AllowCustomConnection  = true;
MyLogonInfo.ConnectionInfo.UserID  = "";
MyLogonInfo.ConnectionInfo.Password = "";                        
                               
}
MyTable.Location = MyTable.Location.SubstringMyTable.Location.LastIndexOf(".")+1);
MyTable.ApplyLogOnInfo(MyLogonInfo);          
                           
}                    
}
               catch( Exception logonInfoException )
               {
                    throw logonInfoException;
               }
          }
 
0
 

Author Comment

by:GCCvanDorth
ID: 12517880
No, I didn't miss the location settings, I missed the CR9.0 service pack of October. It works fine with this package.
0
 
LVL 10

Accepted Solution

by:
ebolek earned 1000 total points
ID: 12525694
Glad it is resolved
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question