Barcode scanning

Hi All,

I am working on a c# winforms application, which should read the barcode value when scanned from barcode sanner pick the required information from database and display that on the screen.

Till now i have worked on such applications, where i will have a cursor on some textbox control, when the user scans the barcode, it will be printed on the textbox. Based on the value on the textbox I use to write a query to get the value from database. But with the new application, it is told that there will be no control on the screen, It is told that if the user keeps the screen active and scans the barcode, the application should read the scanned value and get data from database and print that on the screen.

Can anyone please help me in getting the barcode value without having the control on the screen.

Thanks in advance,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sathish DVSoftware EngineerCommented:
Hi Rajeev,

As per my understanding, in your previous projects you use to scan the barcode and set it values directly to textbox say for eg. txtBarcode be your text box name. So you have set the value of barcode directly to text box like txtBarCode.Text = <scanned value from scanner>, then u might read the data from text box as string someVal = txtBarcode.Text and pass the someVal to database to query the database.
Instead set the string variable directy from scanned value like string someVal = <scanned value from scanner>, then you can use the same the existing code to fetch the data from database.
Check if this helps you. If not is it possible to post some sample code on you set data to  textbox?

rajeeva_nagarajAuthor Commented:
Thanks for the reply Sathish,

I am looking at the C# code which can catch the value in to a variable. If you could get me the sample code, that will be nice for me.

I don't have my VS at hand, but I'll try a quick outline ...

The usual scanners for your "old" application worked probably by slicing the device into the keyboard cable (not literally, but with some kind of Y cable). When the user scans, the input is fed into the keyboard queue and processed similar.

The async usage works on another way ... the scanner in that case sends its data automatically via some more "industrial" interface, like as serial interface (RS232, V.24, RS485, a industrial field bus interface like CAN bus or I2C etc, or possibly socket acces on Ethernet ... there are much possiblities).

Your program would have to connect that interface and implement to get events if data arrives, and it would have to sort out complete and valid datasets for processing. The data may arrive in various formats, depending on your preferred device. The most easy way would be ASCII, like [STX]<ascii data>[ETX], but there are various flavours of that around. Depending on the code to read and the used scanner, the data may be in some kind of binary format, could contain check sum parts, and other nasty strings attached. After receiving a complete dataset, your code needs to take the needed measures like servicing any other event (i.e. as having got a button pess)

I've done such software myself (with an easy config: RS232 interface, plain ASCII data), but the implementation depends much on your detailled config.

Can you elaborate a bit more on your configuration ?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.