this is code i use to call in a record using a textbox and a button

Dim SearchProduct As String = txtBC.Text

    Dim con As OleDbConnection = New OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0;" & _
                 "Data Source = '" & Application.StartupPath & "\POS.mdb'")
    ' Use wildcard' 
    Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Products WHERE SKU= '" & SearchProduct & "' ", con)
    'Like state = "SELECT * FROM Products WHERE SKU Like '%" & SearchProduct & "%' ", con

    con.Open()

    Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
    Dim POSDataSet1 As DataSet = New DataSet()
    If myDA.Fill(POSDataSet1, "Products") Then
        DataGridView1.DataSource = POSDataSet1.Tables("Products").DefaultView
    ElseIf txtBC.Text = "" Then
        BarcodeError2.Show()
    Else
        BarcodeError.Show()
    End If
    txtBC.Text = ""

it inserts the record into my datagridview fine but when i enter the second it just replaces the first record scanned. can some please help me, i have been trying for days to get this to function correctly

Thanks
Carl

You are creating a new DataSet each time you run this code so the table your DataGridView is using gets refreshed with only the record queried for.

You might try using the Datareader to fill the DataTable you're using for your DataGridViews DataSource.

You can create some variables to hold the values read from the DataReader then ad them to your DataTable
You should also use the BindingSource so its easier to refresh your DataGridView.

 Dim newRow As DataRow = ds.Tables("TableName").NewRow()

        newRow("FieldName1") = "SomeValue1"
        newRow("FieldName1") = "SomeValue2"

        ds.Tables("TableName").Rows.Add(newRow)

Give me a shout if you need help setting it up.

hi yeah i forgot to mention i'm a total beginner in programming so your help in setting it up would be greatly appreciated :D

If you are a total beginner in programming then I suggest a simpler project to get your feet wet.

commented: Talk of a wise man. +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.