SQLMAN1951
asked on
Crystal Reports 10 and VS.NET 2005 Error - "The request could not be submitted for background processing."
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.GetDirector yName(Syst em.Windows .Forms.App lication.E xecutableP ath) + @"\" + "Slide.rpt";
try
{
TableLogOnInfo crTableLogOnInfo;
ConnectionInfo crConnectionInfo = new ConnectionInfo();
CrystalDecisions.CrystalRe ports.Engi ne.ReportD ocument doc =
new CrystalDecisions.CrystalRe ports.Engi ne.ReportD ocument();
doc.Load(filePath);
crConnectionInfo.ServerNam e = SQLCONN.gServerName.ToStri ng();
crConnectionInfo.DatabaseN ame = 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.Connectio nInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crT ableLogOnI nfo);
}
doc.SetParameterValue("@St artAccessi onNo", sAccessionNo.ToString()); //sAccessionNo is the input param.
doc.SetParameterValue("@En dAccession No", sAccessionNo.ToString());
doc.PrintOptions.PrinterNa me = PrnName; // input paramteter
doc.PrintToPrinter(1,false ,1,1);
Thank you.
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.GetDirector
try
{
TableLogOnInfo crTableLogOnInfo;
ConnectionInfo crConnectionInfo = new ConnectionInfo();
CrystalDecisions.CrystalRe
new CrystalDecisions.CrystalRe
doc.Load(filePath);
crConnectionInfo.ServerNam
crConnectionInfo.DatabaseN
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.Connectio
crTable.ApplyLogOnInfo(crT
}
doc.SetParameterValue("@St
doc.SetParameterValue("@En
doc.PrintOptions.PrinterNa
doc.PrintToPrinter(1,false
Thank you.
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(crT ableLogOnI nfo);
crTable.Location = crTableLogOnInfo.TableName ;
dylan
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(crT
crTable.Location = crTableLogOnInfo.TableName
dylan
ASKER
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
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
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.PrintOpti ons.Printe rName = pd.PrinterSettings.Printer Name;
crReportdocument.PrintToPr inter(1, False, 0, 0);
pd.Dispose();
dylan
using System.Drawing.Printing;
.......
PrintDocument pd = new PrintDocument()
crReportdocument.PrintOpti
crReportdocument.PrintToPr
pd.Dispose();
dylan
ASKER
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
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
Does your coworker have a default printer set?
mlmcc
mlmcc
ASKER
Yes.
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
http://support.businessobjects.com/downloads/updates/service_packs/crystal_reports.asp
dylan
ASKER
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
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
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
dylan
What code are you using to print the reports?
mlmcc
mlmcc
ASKER
Here is the code that generates the labels.
/************************* ********** ********** ********** ********** ********** ***
** File:
** Name: stpuw_consult_labels_barco des
** 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),@SlideLabelSe quence 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_b ase @EncodeBase out
--Get the material identifiers to append to the encoded material (to identify the type of material)
EXEC stp_get_barcode_material_i dentifiers @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_labe l),'')
FROM #ConsultLabels
ORDER BY accession_no,
CHARINDEX(',' + specimen_label + ',', @SpecimenLabelSequence),
CHARINDEX(',' + block_label + ',', @BlockLabelSequence),
CHARINDEX(',' + convert(varchar(4), slide_label) + ',', @SlideLabelSequence)
END
/*************************
** File:
** Name: stpuw_consult_labels_barco
** 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),@SlideLabelSe
@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_b
--Get the material identifiers to append to the encoded material (to identify the type of material)
EXEC stp_get_barcode_material_i
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),
FROM #ConsultLabels
ORDER BY accession_no,
CHARINDEX(',' + specimen_label + ',', @SpecimenLabelSequence),
CHARINDEX(',' + block_label + ',', @BlockLabelSequence),
CHARINDEX(',' + convert(varchar(4), slide_label) + ',', @SlideLabelSequence)
END
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
dylan
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://support.businessobjects.com/library/kbase/articles/c2013151.asp
http://support.businessobjects.com/library/kbase/articles/c2017982.asp
http://support.businessobjects.com/library/kbase/articles/c2017617.asp