Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
725
UpdateData and Grid with manually defined schema
posted

 

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. 

Parents Reply Children