I have a grid (Infragistics.Win.UltraWinGrid.UltraGrid v11.1) editable and updateable, where I set it manually and run-time allocation of the Grid's DataSource to a DataSet manually defined,Me.Grid.DataSource = pDataSet.Tables ("ARTICLES"): Private Sub FillArticles() Dim cm As IDbCommand Dim dp As IDataParameter 'create command cm = cn.CreateCommand 'create Adapter pAdArticulos = MDatos.DataAdapterCrear(cm) 'create dataset pDataSet = New DataSet 'create datatable pDtArticulos = New DataTable("ARTICLES") 'add datatable to dataset pDtArticulos = pDataSet.Tables.Add("ARTICLES") 'create el parameter dp = MDatos.ConexionParameter(cm, "ART_EMPRESA", pIdEmpresa) 'dml cm.CommandText = " SELECT ART_EMPRESA, ART_ARTICULO, V_ASP_ART_DESCRIPCION, ART_FAMILIA, ART_FAMILIA_ALTERNATIVA" cm.CommandText &= " FROM " & MDatos.BDOwner(cn, "EMRES_ARTICLES", "main") cm.CommandText &= " WHERE ART_EMPRESA = " & dp.ParameterName cm.CommandText &= " ORDER BY ART_ARTICULO" 'fill dataset with table ARTICLES pAdArticulos.Fill(pDataSet, "ARTICLES") 'define primary key pDtArticulos.PrimaryKey = New DataColumn() {pDtArticulos.Columns("ART_EMPRESA"), pDtArticulos.Columns("ART_ARTICULO")} 'assigned DataSet to DataSource Me.Grid.DataSource = pDataSet.Tables("ARTICLES") Me.Grid.DisplayLayout.Bands(0).Columns("ART_EMPRESA").Hidden = True Me.Grid.DisplayLayout.Bands(0).Columns("ART_ARTICULO").Width = 120 Me.Grid.DisplayLayout.Bands(0).Columns("ART_FAMILIA").Width = 220 Me.Grid.DisplayLayout.Bands(0).Columns("ART_FAMILIA_ALTERNATIVA").Width = 220 End Sub When making any change, delete or insert a new row in the grid, the grid detects changes, and in the event AfterRowUpdate, I execute the UpdateData, but changes are not saved in the database. Private Sub Grid_AfterRowUpdate(sender As Object, e As Infragistics.Win.UltraWinGrid.RowEventArgs) Handles Grid.AfterRowUpdate 'exit cell editing to save your changes Me.Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode) Try Me.Grid.UpdateData() Catch ex As Exception Throw ex End Try End Sub How can I define it to save the changes automatically when you run Me.GridUdateData??? Thank for advance(Any code example to set the grid's DataSource manually, please??), but changes are not saved in the database.
Hi,
There is no reason to call the UpdateData method inside AfterRowUpdate. That line of code will do nothing.
UpdateData commits all changes in the grid to the underlying data source. AfterRowUpdate fires after the row's data has already been committed. So this is just redundant.
ddol said:but changes are not saved in the database.
The grid has no direct interaction with the database - it only deals with the local data source. So writing changes from the DataSet back to the database is outside the grid's purview.
Typically, you would use a DataAdapter to retrieve and update data to and from a DataSet. For more information on the DataAdapter, you will need to check out Microsoft's documentation.
The DataSet and DataAdapter pAdArticulos is associated with: pAdArticulos.Fill (pDataSet, "ARTICLES")with what changes should be saved in the database.At what point I will have to execute 'Me.Grid.UpdateData()' to save changes?The way in which I am using the grid and I associating DataSource is correct?Some code samples?