Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want print report directly to printer without show preview of crystal report
so i was used thid code but i got message tell me that missing parameter values
this code:

What I have tried:

Quote:

public void PrintReport()
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"C:\Users\USER\Desktop\my Activies\OldMurbad\Murbad\Murbad\RPT\PrintInvoice.rpt");
cryRpt.SetParameterValue("@IDorder", txtInvoiceNo.Text);





TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;

crConnectionInfo.ServerName = @"DELL\SQLEXPRESS";
crConnectionInfo.DatabaseName = @"Murbad1";
crConnectionInfo.UserID = @"IBRA";
crConnectionInfo.Password = @"IBRA";

CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}

cryRpt.Refresh();
cryRpt.PrintToPrinter(1, true, 0, 0);
}
Posted
Updated 23-Nov-16 7:20am

1 solution

It seems that your report is expecting values for parameter fields that are defined in the report.

The easiest way is to open the report and have a look at the definitions. Refer to Crystal Reports Parameters[^]
 
Share this answer
 
Comments
Member 11310281 24-Nov-16 11:41am    
thank you to put answer, but im using stored procedures in sql server.
Do you have any experience how to use c# with sql server
Wendelius 24-Nov-16 14:30pm    
What is the exact error you get?
Is it from Crystal or from SQL Server?
Member 11310281 25-Nov-16 17:14pm    
I have got message
An unhandled exception of type 'CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException' occurred in CrystalDecisions.CrystalReports.Engine.dll

Additional information: Missing parameter values.
_____________________________________________________
this is code of sql server:
create proc [dbo].[MyInvoice]


@IDorder int

as

SELECT
[Order_ID],
[ProductName],
[Quantities]
,[Price]
,[Discount]
,[SaleMan]

FROM [dbo].[OrderDetails]
where Order_ID=@IDorder

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900