CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Location
    Cardiff and Oxford
    Posts
    44

    Some please help me!!!

    I cannot get my bound datagrid to update once I have updated
    the datagrid and clicked a save button. Here is my code, someone please help.


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

    AdjustStockDtgLoad()

    End Sub



    Private Sub AdjustStockDtgLoad()

    Dim sqlQuery As String = "select * from stockLevels"
    stockLevelsDataSet.Clear()
    adminDataAdapter.SelectCommand.CommandText = sqlQuery
    adminDataAdapter.Fill(stockLevelsDataSet, "stockLevels")

    Dim dataTable As DataTable = stockLevelsDataSet.Tables(0)

    dtgAdjStockLevel.SetDataBinding(stockLevelsDataSet, "stockLevels")

    End Sub




    Private Sub cmdAdjSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdjSave.Click
    Try

    adminDataAdapter.Update(stockLevelsDataSet, "stockLevels")

    dtgAdjStockLevel.Enabled = False
    Catch ex As System.Data.OleDb.OleDbException

    MsgBox(ex.ToString())

    End Try
    End Sub

  2. #2
    Join Date
    Mar 2003
    Location
    Cardiff and Oxford
    Posts
    44
    Just to clarify what exactly I mean. I have managed to bind a datagrid from a dataAdapter. T
    he data loads in fine.
    When the Data is in the table I want to edit the cells and update the original access database uppon click of a save command.

  3. #3
    Join Date
    Jan 2002
    Posts
    17
    I'm still not sure how this works or if it's the right solution, but it worked for me.

    Add the following statement before your update:

    dim aCommandBuilder as new OleDbcommandBuilder(adminDataAdapter)

    You can look at documentation for OleDbCommandBuilder for explanation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured