PrintToPrinter gives LogOnException

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?
GCCvanDorthAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GCCvanDorthAuthor Commented:
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
mlmccCommented:
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
ebolekCommented:
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
GCCvanDorthAuthor Commented:
No, I didn't miss the location settings, I missed the CR9.0 service pack of October. It works fine with this package.
0
ebolekCommented:
Glad it is resolved
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.