?
Solved

Crystal Reports 10 and VS.NET 2005 Error - "The request could not be submitted for background processing."

Posted on 2006-03-27
16
Medium Priority
?
738 Views
Last Modified: 2012-06-27
I am trying to print the CR report without displaying the report and I am having the error ( "The request could not be submitted for background processing.") when it tries to assign the Printer Name to the cr object.
I am using VS.2005 and Crystal Report 10. Any help on this would be appreciated.

The following is the code
           Database crDatabase;
           Tables crTables;
           Table crTable;
           string filePath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + @"\" + "Slide.rpt";
           try
           {
               TableLogOnInfo crTableLogOnInfo;
               ConnectionInfo crConnectionInfo = new ConnectionInfo();
               CrystalDecisions.CrystalReports.Engine.ReportDocument doc =
               new CrystalDecisions.CrystalReports.Engine.ReportDocument();
               doc.Load(filePath);
               crConnectionInfo.ServerName = SQLCONN.gServerName.ToString();
               crConnectionInfo.DatabaseName = SQLCONN.gDBName.ToString();
               crConnectionInfo.UserID = Global.CurrentUserName;
               crConnectionInfo.Password = Global.UserPassword;
               crDatabase = doc.Database;
               crTables = crDatabase.Tables;
               for (int i = 0; i < crTables.Count; i++)
               {
                   crTable = crTables[i];
                   crTableLogOnInfo = crTable.LogOnInfo;
                   crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                   crTable.ApplyLogOnInfo(crTableLogOnInfo);
               }
               doc.SetParameterValue("@StartAccessionNo", sAccessionNo.ToString()); //sAccessionNo is the input param.
               doc.SetParameterValue("@EndAccessionNo", sAccessionNo.ToString());
               doc.PrintOptions.PrinterName = PrnName; // input paramteter
               doc.PrintToPrinter(1,false,1,1);

Thank you.
0
Comment
Question by:SQLMAN1951
  • 7
  • 5
  • 2
  • +1
15 Comments
 
LVL 42

Expert Comment

by:frodoman
ID: 16305255
0
 
LVL 8

Expert Comment

by:dylanyee
ID: 16307431
Instead of print to printer, if you view your report using reportviewer, does it give you the same problem as well?

And in your code, you should setup your table's locations as well or else you will have problem if deploy the report to other pc and datasource.
crTable.ApplyLogOnInfo(crTableLogOnInfo);
crTable.Location = crTableLogOnInfo.TableName;

dylan
0
 

Author Comment

by:SQLMAN1951
ID: 16323918
Dylan,

We don't have a problem with reportviewer, but the issue may lie in our network. Initially when we had a default printer assigned to the report we got it to print. Removing/changing the default printer caused printing to fail. It acts like it wants to print, but the job goes into a black hole. reassigning the default printer didn't correct the problem. We have another report in the same application that works fine to a laser printer. This particular report has to go to a Zebra label printer. We have reinstalled the drivers, with no success.

Victor
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 8

Expert Comment

by:dylanyee
ID: 16328612
This is the code that I use to send my report to printer, it works fine whenever I change my default printer. Pls take a look.

using System.Drawing.Printing;
.......
PrintDocument pd = new PrintDocument()
crReportdocument.PrintOptions.PrinterName = pd.PrinterSettings.PrinterName;
crReportdocument.PrintToPrinter(1, False, 0, 0);
pd.Dispose();

dylan
0
 

Author Comment

by:SQLMAN1951
ID: 16334776
Dylan,

I am working as the middle person on this project. My co-worker said he still gets the same error. It seems the report document could not take a printer name or something.

Victor
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16338516
Does your coworker have a default printer set?

mlmcc
0
 

Author Comment

by:SQLMAN1951
ID: 16345021
Yes.
0
 
LVL 8

Expert Comment

by:dylanyee
ID: 16357082
sorry SQLMAN1951, I have no idea anymore if your co-worker applied my code but still can't get it to work... probably download the latest service pack and try?
http://support.businessobjects.com/downloads/updates/service_packs/crystal_reports.asp

dylan
0
 

Author Comment

by:SQLMAN1951
ID: 16361857
Dylan,

Yes he tried your code. Let me provide a little more info that may or may not make a difference. Originally, the app was going to call and print one report to a laser printer. We are trying to add a second report. but it will be going to a Zebra label printer. The second report was not part of the original plan, but a work around as the Zebra report gets a division by zero error when trying to print from our vendor's database app. There are no formulas in the report and it works great outside the database app.

Victor
0
 
LVL 8

Expert Comment

by:dylanyee
ID: 16366875
Hmm.. if there is no formulas in the report, then it must be the sql select statement which having a calculation field caused the problem.

dylan
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16366947
What code are you using to print the reports?

mlmcc
0
 

Author Comment

by:SQLMAN1951
ID: 16371893
Here is the code that generates the labels.

/******************************************************************************
**            File:
**            Name: stpuw_consult_labels_barcodes
**            Desc: Print barcodes on outside slides and blocks, modification of stpuw_consult_labels
**
**            
**              
**            Return values:
**
**            Called by:  
**              
**            Parameters:
**            Input                                          Output
**     Accession_no                                    Accession No and material label
**
**            Auth: Victor Tobias
**            Date: 1/4/06
*******************************************************************************
**            Change History
*******************************************************************************
**            Date:            Author:                        Description:
**            --------      --------            -------------------------------------------
**          
*******************************************************************************/
BEGIN
DECLARE @SpecimenLabelSequence varchar(255),@CaseId int, @status char(1),
          @BlockLabelSequence varchar(255),@SlideLabelSequence varchar(255), @order_status char(5),
        @PrintSpecimenLabel varchar(255), @StartSeries varchar(20), @EndSeries varchar(20), @Year int, @Number int

  SET NOCOUNT ON
  /* Decode accession numbers. Allows lab to enter shortcuts and have report expand, i.e.
     SU55 = SU-99-00055
  */
  EXEC stp_decode_accession_no @StartAccessionNo, @StartSeries out, @Year out, @Number out
  EXEC stp_encode_accession_no @StartSeries, @Year, @Number, @StartAccessionNo out

  EXEC stp_decode_accession_no @EndAccessionNo, @EndSeries out, @Year out, @Number out
  EXEC stp_encode_accession_no @EndSeries, @Year, @Number, @EndAccessionNo out


  EXEC  stp_get_appreg_node_value '\System Options\Management Reports\Slide Label\Print Specimen Label If One Specimen', @PrintSpecimenLabel out

  SELECT @PrintSpecimenLabel = RTRIM(@PrintSpecimenLabel)

  EXEC stp_Get_Label_Sequence 'S', @SpecimenLabelSequence out
  EXEC stp_Get_Label_Sequence 'B', @BlockLabelSequence out
  EXEC stp_Get_Label_Sequence 'L', @SlideLabelSequence out


CREATE TABLE #ConsultLabels(
  case_id int NULL,
  accession_no varchar(30) NULL,
  case_type varchar(30) NULL,
  patient_name varchar(80) NULL,
  specimen_desc varchar(80) NULL,
  specimen_label varchar(5) NULL,
  block_label varchar(5) NULL,
  slide_label int NULL,
  row_type varchar(30) NULL,
  rec_type varchar (1) NULL,
  Material_ID int null,
  encoded_material_id varchar(25) NULL
 
)


/* Get blocks */
INSERT INTO #ConsultLabels(
        case_id, accession_no, case_type, patient_name, specimen_desc, specimen_label, block_label,
      slide_label, row_type, rec_type, Material_id
      )
SELECT  a.id,
      a.accession_no,
      act.name,
      (p.last_name + ' ,' + p.first_name),
      sp.description,
           CASE WHEN @PrintSpecimenLabel = 'N' AND
               ((SELECT COUNT(*) FROM  acc_specimen (nolock) where acc_id = sp.acc_id) = 1)
               THEN NULL ELSE sp.specimen_label
          END,
      ab.label,
      NULL,
      'Block',
      'B',
      ab.id
FROM      accession a (NOLOCK)
          JOIN patient p (NOLOCK) ON p.id = a.patient_id
          JOIN acc_type act (NOLOCK) ON act.id = a.acc_type_id
          JOIN acc_block ab (NOLOCK) ON ab.acc_id = a.id AND ab.type = 'C' /* Only get consult blocks */      -- RC removed 7/20/04, uncommented 7/29/04
          JOIN acc_specimen sp (NOLOCK) ON sp.id = ab.acc_specimen_id
WHERE     (@StartSeries = @EndSeries) /* Make sure to only return data if range is in same accession series */
          AND (a.accession_no >= @StartAccessionNo)
          AND (a.accession_no <= @EndAccessionNo)


/* Get slides */
INSERT INTO #ConsultLabels(
          case_id, accession_no, case_type, patient_name, specimen_desc, specimen_label,
          block_label, slide_label, row_type, rec_type, Material_id)
SELECT  a.id,
      a.accession_no,
      act.name,
      (p.last_name + ' ,' + p.first_name),
      sp.description,
           CASE WHEN @PrintSpecimenLabel = 'N' AND
               ((SELECT COUNT(*) FROM  acc_specimen (nolock) where acc_id = sp.acc_id) = 1)
               THEN NULL ELSE sp.specimen_label
          END,
      NULL,
      asl.slide_no,
      'Slide',
      'L',
      asl.id
FROM      accession a (NOLOCK)
          JOIN patient p (NOLOCK) ON p.id = a.patient_id
          JOIN acc_type act (NOLOCK) ON act.id = a.acc_type_id
          JOIN acc_slide asl (NOLOCK) ON asl.acc_id = a.id AND asl.type = 'C' /* Only get consult blocks */      -- RC removed 7/20/04, uncommented 7/29/04
          JOIN acc_specimen sp (NOLOCK) ON sp.id = asl.acc_specimen_id
WHERE     (@StartSeries = @EndSeries) /* Make sure to only return data if range is in same accession series */
          AND (a.accession_no >= @StartAccessionNo)
          AND (a.accession_no <= @EndAccessionNo)

-------------------bar coding section
-------------------fills the encoded_material_id JLH
 
      DECLARE      @EncodeBase int, @CaseIdentifier varchar(1), @SpecimenIdentifier varchar(1), @BlockIdentifier varchar(1),
            @SlideIdentifier varchar(1)
      
      --Get the base to encode to
      EXEC stp_get_barcode_encoding_base @EncodeBase out
      
      --Get the material identifiers to append to the encoded material (to identify the type of material)
      EXEC stp_get_barcode_material_identifiers @CaseIdentifier out, @SpecimenIdentifier out, @BlockIdentifier out, @SlideIdentifier out
      
      DECLARE @SlideID int, @MaterialType varchar(5), @EncodedMaterial varchar(25), @FullLabel varchar(25), @SlideLabel smallint
      SET NOCOUNT ON
      DECLARE material_cursor CURSOR FOR
      SELECT      DISTINCT Material_ID, rec_type --, orginal_slide_no -- TT3967
      FROM      #ConsultLabels
      WHERE      rec_type in ('L', 'B')  -- specimens or control slides.
      
      OPEN      material_cursor
      
      FETCH NEXT FROM material_cursor INTO @SlideID, @MaterialType --, @SlideLabel
      WHILE (@@Fetch_Status <> -1)
      BEGIN
            IF @MaterialType = 'L' BEGIN
                  --Get the material's label
                  EXEC stp_get_material_label @SlideID, @MaterialType, @FullLabel out
            
                  EXEC stp_encode_barcode_value @SlideIdentifier, @SlideID, @EncodeBase, @EncodedMaterial out
                  --EXEC stp_encode_barcode_value @SlideIdentifier, @SlideID, @EncodeBase, @stringSlideID out
                  -- use custom encode 128 PN
                  --exec stpuw_ComputeCode128 @stringSlideID, @EncodedMaterial out      
            END
            ELSE BEGIN
                  --Get the material's label
                  EXEC stp_get_material_label @SlideID, @MaterialType, @FullLabel out
            
                  EXEC stp_encode_barcode_value @BlockIdentifier, @SlideID, @EncodeBase, @EncodedMaterial out
            END
                                          
            if @EncodedMaterial is not null
                  UPDATE #ConsultLabels SET encoded_material_id = @EncodedMaterial
                        WHERE Material_ID = @SlideID and rec_type = @MaterialType
                              --and orginal_slide_no = @SlideLabel -- TT3967
            
            FETCH NEXT FROM material_cursor INTO @SlideID, @MaterialType --, @SlideLabel
      END
      CLOSE material_cursor
      DEALLOCATE material_cursor
 
------------------- end bar coding section ---------------

SET NOCOUNT OFF

/* Return data to report */
SELECT    *
      , full_sbs_label =             -- added by RS 4/19/02
            ISNULL(specimen_label,'') +
            ISNULL(block_label,'') +
            CASE
                  WHEN slide_label is not NULL THEN '-'
                  Else ''
            END +
            ISNULL(convert(varchar(4),slide_label),'')
FROM      #ConsultLabels
ORDER BY  accession_no,
          CHARINDEX(',' + specimen_label + ',', @SpecimenLabelSequence),
          CHARINDEX(',' + block_label + ',', @BlockLabelSequence),
          CHARINDEX(',' + convert(varchar(4), slide_label) + ',', @SlideLabelSequence)
END
0
 
LVL 8

Expert Comment

by:dylanyee
ID: 16377386
I don't see any division action in your stored procedure... its strange that you will get the "division by zero" error when printing... are you sure that you don't have any formula in your report? or maybe you have to do some debugging process, take off fields one by one to see which is causing the problem...

dylan
0
 

Author Comment

by:SQLMAN1951
ID: 16447464
Can someone close this as currently there is no resolution. I finally got some support from our LIS vendor and they can reproduce the problem, but no resolution yet. They believe it is with the printer drivers. Thank you all for your efforts.
0
 

Accepted Solution

by:
SQLMAN1951 earned 0 total points
ID: 16454554
Since I posted my last comment, our LIS vendor was able to resolve the problem so it will print fom within their application. The report started life in CR8.5.  The vendor forced us to upgrade to CR10 and the report was converted and worked well until this last round of tweaking and then it broke. The vendor rebuilt it from scratch in CR10 and it works great. Thank you all.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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 …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 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