How to update GridControl(Devexpress)


  • Hey MS Developers,
    i have recently uploaded a ticket on Devexpress Ticket Support for "HOW TO UPDATE GRIDCONTROL" and they give me a Code for updating, Code in below:

    Public Sub New()
           GridControl1.DataSource = GetDataTable(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Tables & Queries\OFFICEONCLOUD_Database_in.accdb", "expense", "SELECT expense.Employees, expense.Date, expense.Description, expense.Category, expense.Amount FROM expense; ")
    			gridView1.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Top
    		End Sub
    		Private adapter As OleDbDataAdapter
    		Private results As DataTable
    		Private conn As OleDbConnection
            Private Function GetDataTable(ByVal DBpath As String, ByVal TableName As String, ByVal format As String) As DataTable
                Dim connString As String = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;data source={0}", DBpath)
                results = New DataTable()
                conn = New OleDbConnection(connString)
                Dim cmd As New OleDbCommand(String.Format("SELECT * FROM {0}", TableName), conn)
                adapter = New OleDbDataAdapter(cmd)
                Dim builder As New OleDbCommandBuilder(adapter)
                adapter.SelectCommand = cmd
                Return results
            End Function
            Private Sub GridControl1_EmbeddedNavigator_ButtonClick(sender As Object, e As DevExpress.XtraEditors.NavigatorButtonClickEventArgs) Handles GridControl1.EmbeddedNavigator.ButtonClick
            End Sub

    This code is update well in this project that Devexpress give me and this project is running with the Database that Devexpress give with the project, but when i change the Database location that indicate my database so visual basic gives an error ""Syntax error in UPDATE statement. 

    Please help what i do

    Thursday, August 01, 2013 6:46 PM