Hey guys

I am creating a till system (EPOS system) in vb.net
I have a textbox and a datagrid and I am using SQL Server 2005 as a DBMS.

I have already managed to retrieve data into the datagrid by typing in an item number into the textbox, hitting a button, and the items details are retrieved into the datagrid.

Now the problem arises once I type in another item number into the text box. The details of the new item replace the current details already in the datagrid.

How could I do it so that all the different item details stay in the datagrid?

Is it possible?
I have tried looking in previous posts but couldnt find any aid for this problem

Thanks guys, I appreciate your help


Refresh Datagrid.

Hey Jx_man, thanks for your reply. I have already attempted that however it isnt making a difference.

The old sql query result keeps getting replaced by the new query result.:-/

post your insert code

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim da1 As New SqlDataAdapter
        Dim ds1 As New DataSet

        da1 = New SqlDataAdapter("select * from items where [item_ID]='" & txtSearch.Text & "'", con)
        DataGridView1.DataSource = ds1.Tables(0)

    End Sub

I have started researching into ways of storing the query result into the datagrid, so that it doesnt keep getting replaced with a new query result. I dont know if thats a lead??

Thanks again for your time

Hey guys,

I have managed to solve this problem.

This was done by storing previous SQL query results as a string and then with use of an If statement.

If the string is empty, fill it with the data in the textbox. Else if its not empty store all data as a string and that way it can be retrieved into one box.

Enter this somewhere in the page dim strSearch as string Enter this code in the button:

If strSearch = "" then
    strSearch = txtSearch.Text
    strSearch = strSearch & " ' or [item ID] = ' " & txtSearch.Text
End if

("Select * from items where [item ID] = ' " & strSearch & " ' ", con)

And thats the solution to the problem:)

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.