So I guess this is the correct forum?
I am trying to scan a bar code into a text box and then populate a grid view with the results of the SQL statement.
Using Access I would use the "after update" event of the text box and put the code there. So where do I put the code in VB '10?
When I scan the barcode while the cursor is blinking in the text box it puts the number in the text box. The Scanner is programmed to also send an "Enter" key sequence. so Access would make it tab over to the next Tab stop. Not VB '10.
in VB '10 I can see the number in the text box, but it ignores the Enter key. In other words it just stays in that box. Scanning a barcare into Notepad it does jump to the next line below after a scan which is normal.
I hard coded the SQL statement to make sure it in fact returned a valid recordset to the grid and it does. but I can't make it work scanning a bar code. I have done this same thing in a myriad of programs over the years so I know what to expect.
I can't even seem to send the value of one text box to another either? I though it was not working since there was only one textbox on the form and it had no place to go. Nope
Also if I put in a breakpoint after the "query" variable it does not have the barcode number, it has this? whatever it means?
"select * from dbo.PickupScans where RFIDTag = 'System.Windows.Forms.TextBox, Text: 8'" So I think it see teh first digit of the number and fires the TextChanged event before the rest of the number is in?
I would expect to see something like:
select * from dbo.PickupScans where RFIDTag = '810326010764' or I did in Access, VB6 and others.
So which Textbox event do I need to use for the barcode scanner and have it put the entire number?
DougP
I am trying to scan a bar code into a text box and then populate a grid view with the results of the SQL statement.
Using Access I would use the "after update" event of the text box and put the code there. So where do I put the code in VB '10?
When I scan the barcode while the cursor is blinking in the text box it puts the number in the text box. The Scanner is programmed to also send an "Enter" key sequence. so Access would make it tab over to the next Tab stop. Not VB '10.
in VB '10 I can see the number in the text box, but it ignores the Enter key. In other words it just stays in that box. Scanning a barcare into Notepad it does jump to the next line below after a scan which is normal.
I hard coded the SQL statement to make sure it in fact returned a valid recordset to the grid and it does. but I can't make it work scanning a bar code. I have done this same thing in a myriad of programs over the years so I know what to expect.
I can't even seem to send the value of one text box to another either? I though it was not working since there was only one textbox on the form and it had no place to go. Nope
Code:
Private Sub txtScan_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtScan.TextChanged
Me.TextBox1 = Me.txtScan
Dim connectionString As String
Dim cnn As SqlConnection
connectionString = "Data Source=P4SCREAMER\SQLEXPRESS;Initial Catalog=StudentPickup;Integrated Security=SSPI;"
cnn = New SqlConnection(connectionString)
Try
cnn.Open()
Dim query As String
query = "select * from dbo.PickupScans where RFIDTag = '" & Me.txtScan.ToString & "'"
'query = "select * from dbo.PickupScans where RFIDTag = '810326010764'" < this works hardcoded
Dim da As New SqlDataAdapter
Dim dt As New DataTable
'dt.Clear()
da.SelectCommand = New SqlCommand(query, cnn)
da.Fill(dt)
DataGridView1.DataSource = dt
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Information, "Can not open connection ! ")
End Try
cnn.Close()
End Sub
Also if I put in a breakpoint after the "query" variable it does not have the barcode number, it has this? whatever it means?
"select * from dbo.PickupScans where RFIDTag = 'System.Windows.Forms.TextBox, Text: 8'" So I think it see teh first digit of the number and fires the TextChanged event before the rest of the number is in?
I would expect to see something like:
select * from dbo.PickupScans where RFIDTag = '810326010764' or I did in Access, VB6 and others.
So which Textbox event do I need to use for the barcode scanner and have it put the entire number?
DougP