i have a problem when updating database. i need to update stock value in other table and count it and update to another table again.

here the code :

        'in every row on 'SalesDetailBindingSource'
            For Each SalesDetailData In SalesDetailBindingSource
                MsgBox("SalesDetailData : " & SalesDetailBindingSource.Count)

                'dim use to take parameter
                Dim SalesDetailDataRow = CType(CType(SalesDetailData, DataRowView).Row, myDataSet.SalesDetailRow)
                Dim paramTransactionNumber = TransactionNumberTextBox.Text

                'parameter need : (paramProductId)
                Dim paramProductId = SalesDetailDataRow.ProductId

                'row to find in table 'SalesDetail'
                Dim SalesDetailRow As myDataSet.SalesDetailRow
                SalesDetailRow = myDataSet.SalesDetail.FindByTransactionNumberProductId(paramTransactionNumber, paramProductId)

                'in every row found
                For Each SalesDetailRowToFind In SalesDetailRow.Table.Rows

                    'here is the problem (i think)
                    'update to 'Stock' table
                    Dim stockRow As myDataSet.stockRow = myDataSet.stock.FindByProductId(paramProductId)
                    For Each stockRowData In StockBindingSource
                        Dim paramStockOut As Integer = stockRow.StockOut + TotalTextBox.Text
                        stockRow.StockOut = paramStockRakOut

                    'update to 'Plu' table
                    Dim pluRow As myDataSet.pluRow = myDataSet.plu.FindByProductId(paramProductId)
                    For Each pluRowData In PluBindingSource
                        Dim paramStockTotal As Integer = (stockRow.StockIn - stockRow.StockOut)
                        pluRow.Stock = paramStockTotal


Edited 3 Years Ago by alwayslearn: wrong code

In wich line of your code you obtained the:

update database (object reference not set to an instance of an object)


This article has been dead for over six months. Start a new discussion instead.