Israel

Israel

  • 698
  • 1.3k
  • 217.7k

Doesnt read correctly my barcode

Jun 8 2017 6:52 PM
Hi!
 
I am try to read my barcode with a barcode reader.
For example, I have a product with this barcode: 500148492783
Curiosly when I shoot on my barcode product its try to filter and suddently its stops and says this product doesnt exit. Its reads only the number 5 and cant continue to read the whole barcode.
This is my code:
 
private void txtCodProduct_KeyUp(object sender, KeyEventArgs e)
{
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\App_Datas\test1.mdb;Persist Security Info=False";
OleDbConnection sqlCon = new OleDbConnection(connectionString);
sqlCon.Open();
string commandString = "select * from product where cod='" + txtCodProduct.Text + "'";
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
date.Text = read["date"].ToString();
product.Text = read["product"].ToString();
}
}
else
{
MessageBox.Show("this codproduct " + CodProduct.Text + " doesnt exist.");
}
read.Close();
sqlCon.Close();

Answers (3)