none
How to update GridControl(Devexpress)

    Question

  • Hey MS Developers,
    i have recently uploaded a ticket on Devexpress Ticket Support http://www.devexpress.com/Support/Center/Question/Details/Q377842 for "HOW TO UPDATE GRIDCONTROL" and they give me a Code for updating, Code in below:

    Public Sub New()
    InitializeComponent()
           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)
                conn.Open()
                adapter = New OleDbDataAdapter(cmd)
                Dim builder As New OleDbCommandBuilder(adapter)
                adapter.SelectCommand = cmd
                adapter.Fill(results)
                Return results
            End Function
            Private Sub GridControl1_EmbeddedNavigator_ButtonClick(sender As Object, e As DevExpress.XtraEditors.NavigatorButtonClickEventArgs) Handles GridControl1.EmbeddedNavigator.ButtonClick
                adapter.Update(results)
            End Sub

    This code is update well in this project that Devexpress give me www.devexpress.com/Support/Center/Attachment/GetAttachment?fileOid=c82f13e3-f830-11e2-805a-90f65200c402&fileName=Q377842.zip 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

Answers