Tuesday, 13 March 2012

ASP.NET Print a crystal report by code to a specific printer via printer IP and Name

 Dim rdpDocument As New ReportDocument
            Dim crConnectionInfo As New ConnectionInfo()

            crConnectionInfo.ServerName = "MIS-009"
            crConnectionInfo.DatabaseName = "HR_DEV"
            crConnectionInfo.IntegratedSecurity = False
            crConnectionInfo.UserID = "sa"
            crConnectionInfo.Password = "sa"

            rdpDocument.SetDatabaseLogon("sa", "sa")

            rdpDocument.SetDataSource(GetData("@PICKINGROUTEID", "034333_138", "REPORT_TRUCK_CONSIGNMENT"))
            rdpDocument.PrintOptions.PrinterName = "\\\" & "HP Color LaserJet 4700 PS"
            rdpDocument.PrintToPrinter(1, True, 0, 1)         

If you faced any problem or error related to that you can not identify the printer IP or address here some steps to get the printer address

1) Add Printer to server. 2) run regedit 3) Search for printername to find your printer 4) value of uNCName property is printer name you need. oRpt.PrintOptions.PrinterName = "value";

No comments:

Post a Comment