i am having problems editting my record where i basically want to select a record from the datagrid view and change any details where the data is displayed in the text boxes i have put on my form and click edit and have the data updated on to the database as well as the dataset

As for my updating button the code seems ok but i check my database and it doesnt change.
I am slightly new so am at a bit of a stand still any help or advice would be greatly appreciated. here is my code where the edit and update button code are at the bottom:

Imports System.Data.OleDb
Public Class Stock_Control

    Dim dbConnection As OleDbConnection
    Dim dbcommand As OleDbCommand
    Dim dbdataAdapter As OleDbDataAdapter
    Dim connectstring As String = "Provider = Microsoft.Jet.OLEDB.4.0;" & "data source = COMP4.mdb"
    Dim dtStockControl As DataTable

    Dim inc As Integer
    Dim MaxRows As Integer

    Private Sub Stock_Control_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        dbConnection = New OleDbConnection(connectstring)
        dbdataAdapter = New OleDbDataAdapter()
        dtStockControl = New DataTable()
        dbcommand = New OleDbCommand("Stock Control")
        dbcommand.CommandType = CommandType.TableDirect

        dbdataAdapter.SelectCommand = dbcommand
        dbdataAdapter.SelectCommand.Connection = dbConnection
        grdStockControl.DataSource = dtStockControl

        txtMake.DataBindings.Add("Text", dtStockControl, "Make")
        txtModel.DataBindings.Add("Text", dtStockControl, "Model")
        txtPartNo.DataBindings.Add("Text", dtStockControl, "Part No")
        txtProductType.DataBindings.Add("Text", dtStockControl, "Product Type")
        txtQuantity.DataBindings.Add("Text", dtStockControl, "Quantity")
        txtReOrderLevel.DataBindings.Add("Text", dtStockControl, "Re-Order Level")
        txtRetailPrice.DataBindings.Add("Text", dtStockControl, "Retail Price")
        txtSupplierUsed.DataBindings.Add("Text", dtStockControl, "Supplier Used")
        txtWholesalerPrice.DataBindings.Add("Text", dtStockControl, "Wholesaler Price")

    End Sub

    Private Sub btnNextRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNextRecord.Click
        Me.BindingContext(dtStockControl).Position += 1

    End Sub

    Private Sub btnPreviousRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreviousRecord.Click

        Me.BindingContext(dtStockControl).Position -= 1

    End Sub

    Private Sub btnFirstRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirstRecord.Click

        Me.BindingContext(dtStockControl).Position = 0

    End Sub

    Private Sub btnLastRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLastRecord.Click

        Me.BindingContext(dtStockControl).Position = Me.BindingContext(dtStockControl).Count

    End Sub

    Private Sub btnEditStockItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditStockItem.Click

        Dim cb As New OleDb.OleDbCommandBuilder(dbdataAdapter)
        Dim selecteditem As Integer

        SelectedItem = grdStockControl.CurrentRow.Index

        COMP4DataSet.Tables("StockControl").Rows(selecteditem).Item("Product Type") = txtProductType.Text
        COMP4DataSet.Tables("dtStockControl").Rows(selecteditem).Item("Make") = txtMake.Text
        COMP4DataSet.Tables("dtStockControl").Rows(selecteditem).Item("PartNo") = txtPartNo.Text
        COMP4DataSet.Tables("dtStockControl").Rows(selecteditem).Item("Model") = txtModel.Text
        COMP4DataSet.Tables("dtStockControl").Rows(selecteditem).Item("WholesalerPrice") = txtWholesalerPrice.Text
        COMP4DataSet.Tables("dtStockControl").Rows(selecteditem).Item("RetailPrice") = txtRetailPrice.Text
        COMP4DataSet.Tables("dtStockControl").Rows(selecteditem).Item("SupplierUsed") = txtSupplierUsed.Text
        COMP4DataSet.Tables("dtStockControl").Rows(selecteditem).Item("Quantity") = txtQuantity.Text
        COMP4DataSet.Tables("dtStockControl").Rows(selecteditem).Item("ReOrderLevel") = txtReOrderLevel.Text

        dbdataAdapter.Update(COMP4DataSet, "dtStockControl")

        MsgBox("Data was successfully edited", "Stock Control")

    End Sub

    Private Sub btnUpdateStockSystem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateStockSystem.Click
            dbdataAdapter.Update(COMP4DataSet, "Stock Control")
            MsgBox("Stock Control has been successfully updated.", "Stock Control", MsgBoxStyle.OkOnly)

        Catch ex As Exception
            MsgBox("there was an error updating the stock control table.", MsgBoxStyle.OkOnly)
        End Try

    End Sub
End Class

Controls (TextBoxes) are already been bound with datasource. Remove lines from code #69 to #79.

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