Hello everyone!

I am new to VB.Net and I am actually developing a simple POS system. I am using visual studio 2010 and Access 2007.
I created a form where the user can search the database and view the invoice details by entering the invoice id in a textbox. The result is displayed in a datagridview. If there is only one item recorded for the invoice, the result is fine. The problem is that if there are more than one item, I get many results like it is duplicated.
The database is PS and the table is SalesInvoice.
The code is below:

Dim TA As New PSDataSetTableAdapters.SalesInvoiceTableAdapter
        Dim TBL = TA.GetDataByID(TextBox1.Text)

        Dim RW As PSDataSet.SalesInvoiceRow = TBL.Rows(0)

        Dim I As Integer
        For I = 0 To TBL.Rows.Count - 1

            If TBL.Rows(I).Item(0) = TextBox1.Text Then
               
                SalesInvoiceDataGridView.Rows.Add(RW.InvoiceID, RW.InvoiceDate, RW.ItemName, RW.Description, RW.Price, RW.Quantity, RW.Amount, RW.InvoiceTotal)
End If
Next

Any help will be much appreciated please.
Thanks a lot.

Hello everyone!

I am new to VB.Net and I am actually developing a simple POS system. I am using visual studio 2010 and Access 2007.
I created a form where the user can search the database and view the invoice details by entering the invoice id in a textbox. The result is displayed in a datagridview. If there is only one item recorded for the invoice, the result is fine. The problem is that if there are more than one item, I get many results like it is duplicated.
The database is PS and the table is SalesInvoice.
The code is below:

Dim TA As New PSDataSetTableAdapters.SalesInvoiceTableAdapter
        Dim TBL = TA.GetDataByID(TextBox1.Text)

        Dim RW As PSDataSet.SalesInvoiceRow = TBL.Rows(0)

        Dim I As Integer
        For I = 0 To TBL.Rows.Count - 1

            If TBL.Rows(I).Item(0) = TextBox1.Text Then
               
                SalesInvoiceDataGridView.Rows.Add(RW.InvoiceID, RW.InvoiceDate, RW.ItemName, RW.Description, RW.Price, RW.Quantity, RW.Amount, RW.InvoiceTotal)
End If
Next

Any help will be much appreciated please.
Thanks a lot.

try to clear the datagrid first before the search

hello !
i dont have any experience of access , i am writing here code for mssql , hope this will gives you an idea

dim mycon as new sqlconnection("connectionstring")
dim da as sqldataadapter("select * from SaleInvoice where InvoiceID="& val(txtInvoiceID.text),mycon)
dim dt as datatable
da.fill(dt)
datagridview.datasource=dt

this record show all the records of invoice id given in textbox in datagrid , hope this will helps you

Regards

M.Waqas Aslam

Hi.
Thanks everyone!! I solved the problem. I was actually pointing to only the first row of the table. Its working fine now!!!

Thanks again.

This question has already been answered. Start a new discussion instead.