Click here to Skip to main content
15,179,246 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)

My requirement is when i click on default crystal report print button, it will open printoptions window, when i select the Ok button, on button click event i want to insert data into the database(Call method). I have tried so many way but i did't get and then i have changed desgin like i have taken one dropdownlist to bind network printers and then when click on button it will insert data into the db and print starts.

myReportDocument.PrintToPrinter(1, false, 1, 1);

But in local host it is working fine when i moved this to the server i am not able to get printers list. To get printer i have used following code.

First Method:
var queues = server.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local,EnumeratedPrintQueueTypes.Shared,
            foreach (var printer in queues)


Second Method:

foreach (var print in System.Drawing.Printing.PrinterSettings.InstalledPrinters)

Third Method:
System.Management.ObjectQuery oq = new System.Management.ObjectQuery
("SELECT * FROM Win32_PrintJob");
ManagementObjectSearcher query1 = new ManagementObjectSearcher(oq);
ManagementObjectCollection queryCollection1 = query1.Get();
foreach( ManagementObject mo in queryCollection1 )

Please suggest me how can i get network printers. Thanks in advance...

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