How to save records in DB on click of default crystal report print button?
Hi, 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, EnumeratedPrintQueueTypes.Connections}); foreach (var printer in queues) { DdlPrinters.Items.Add(printer.Name); }
Second Method:
foreach (var print in System.Drawing.Printing.PrinterSettings.InstalledPrinters) { DdlPrinters.Items.Add(print); }
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...