title: Filling DataGridView based on a scanned barcode number from a barcode scanner
body: <p>I have been reading loads of questions and answers and even the .NET reference site. The code seems to be good but it's not working as expected.</p>
  
  <p>I have a <code>TextBox</code> where a barcode scanner is used to scan barcodes and put the number in it. Once the barcode is received it has to detect the <kbd>Enter</kbd> key and do a function that searches the database and add the item in a <code>DataGridView</code>. </p>
  
  <p>The code is working but it's only adding 1 item to the <code>DataGridView</code> even if I scan multiple items.</p>
  
  <p>Code:</p>
  
  <pre><code> Private Sub txtmodel_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtmodel.KeyPress
  
      Dim purchasesource As New BindingSource
      If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
  
  
          Dim query As String
          query = "select  prod_name as 'Product Name',prod_cost as 'Cost', prod_price as 'Price' from  product_tbl where prod_STATUS = 'Active' and prod_code = '" &amp; txtmodel.Text &amp; "'"
  
          cmd = New MySqlCommand(query, con)
          da.SelectCommand = cmd
          da.Fill(sql_get_purchase_item)
          purchasesource.DataSource = sql_get_purchase_item
          DataGridView1.DataSource = purchasesource
          da.Update(sql_get_purchase_item)
  
          MsgBox(sql_get_purchase_item.Rows.Count)
  
          barcode = txtmodel.Text 'decaled in the class
  
          TextBox1.Text &amp;= barcode
  
          txtmodel.Focus()
  
          txtmodel.SelectAll()
  
      End If
  
  End Sub
  </code></pre>