Reputation: 1322
Can any body who did some work on related thing tell me how can I achieve this?
What I want to achieve is to read number (printing on my boxes) from scanner and put that number in database. The numbers can be product IDs. What I need to know
Upvotes: 0
Views: 6525
Reputation: 343
What i know is most of new scanners comes with a library or SDK in different programming languages so before you buy ask about one with support library, and if it doesn't come with one i think you can use the SerialPort component in windows forms. This example might help you Using Barcode Reader In C Sharp
Upvotes: 3
Reputation: 44605
As extensively explained here: https://stackoverflow.com/questions/613881/how-to-read-a-value-from-a-barcode-reader a barcode reader/scanner (either parallel, serial or USB connected) is normally seen as a keyboard from the computer, this happens at the device driver level, you have nothing to do about that in your C# code.
In fact you should also support manual entry of the code ( alpha-numeric ), like the cashier does in the supermarket when you took an item with unreadable (by the scanner) barcode.
in your C# application have a textbox where the user can type the code using the keyboard and when focus is on that textbox and the user scans a code with the reader you won't notice any difference between the input coming from the normal keyboard or the reader... no differences except that in some cases the barcode reader will also include a CR ( ENTER ) at the end of the code and you can use that to initiate your next action, like database operation etc.
I think you can actually configure if you want the CR to be sent to you after each read or not, somewhere in the driver settings of the device, it might depend on the specific device.
Upvotes: 5