TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Israel
693
1.3k
219.5k
SOLUTION: Great codes to read data with barcode scanner
Oct 18 2014 9:03 AM
For those are looking for long time to read data with the barcode scanner. These codes will help a lot and works no problem. Thanx
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
string lastScannedCode = "";
public Form1()
{
InitializeComponent();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
lastScannedCode = textBox1.Text;
label1.Text = lastScannedCode;
textBox1.Clear();
}
}
void ShowTheLastScannedCode()
{
MessageBox.Show(lastScannedCode);
}
private void label1_TextChanged(object sender, EventArgs e)
{
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\TestBarcodeReader\WindowsFormsApplication1\WindowsFormsApplication1\App_Data\office.mdb;Persist Security Info=False";
OleDbConnection sqlCon = new OleDbConnection(connectionString);
sqlCon.Open();
string commandString = "select * from barcode where code ='" + label1.Text + "'";
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
label2.Text = read["products"].ToString(); // it will show the code
}
}
else
{
MessageBox.Show("A record with a code of " + label1.Text + " was not found");
}
read.Close();
sqlCon.Close();
}
}
}
Reply
Answers (
1
)
how to display my image on my picturebox with "search"
Spell Checker for Rich Textbox