Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 502
  • Last Modified:

Duplicate rows in TDB8.0

Hi experts,

I am using TDBGrid 8.0 and VB6.
My grid is unbound, using an XArrayDB.

When a new row (row1) gets save/updated (when then user click on another row, the addnew row, row2)
The row1 gets duplicated on the grid (NOT in the database). The record appears twice on the grid (on the row1 as it should, AND on the first row, the one on top of all rows).

Does anybody has an idea why ?
Thanks

gallia
0
Gallia
Asked:
Gallia
  • 2
  • 2
1 Solution
 
appariCommented:

can you post the code related to where you are initializing the xarray (xarray.redim) and filling with initial data etc.
0
 
GalliaAuthor Commented:
Hi appari,

Sorry for the delay, I was away. Here is the code.

    Set objArray = New XArrayDB

    If o_rsData.EOF Then
        objArray.ReDim 0, 0, 0, 0
        o_objGrid.SetNbColumn 0
        'Bind the XArrayDB structure with Grid
        Set o_objGrid.Grid.Array = objArray
        Set o_rsData = Nothing
        Exit Sub
    Else
        objArray.ReDim 0, o_rsData.RecordCount - 1, 0, o_rsData.Fields.Count - 1
        o_objGrid.SetNbColumn o_rsData.Fields.Count
    End If

    'Display titles on column header
    With o_objGrid.Grid.Columns
        For i = LBound(i_vListInfo) To UBound(i_vListInfo)
            .Item(i).ValueItems.Presentation = i_vListInfo(i).Presentation
            If i_vListInfo(i).CaptionID <> 0 Then
                .Item(i).Caption = LoadResString(i_vListInfo(i).CaptionID)
            Else
                .Item(i).Caption = i_vListInfo(i).SystemName
            End If
            .Item(i).Tag = i
            .Item(i).Locked = i_vListInfo(i).Locked
            .Item(i).Width = i_vListInfo(i).DefaultWidth
            If i_vListInfo(i).Format = "" Then
                o_objGrid.SetColFormatADO i, i_vListInfo(i).DataType
            Else
                o_objGrid.SetColFormat i, i_vListInfo(i).Format
                o_objGrid.SetColAlignment i, i_vListInfo(i).Alignment
            End If
            .Item(i).Visible = i_vListInfo(i).Visible
        Next i
    End With

    If Not o_rsData.EOF Then
        'Populate XArrayDB structure
        i = 0
        With o_rsData
            While Not .EOF
                For j = 0 To objArray.Count(2) - 1
                    objArray(i, j) = .Fields(j).Value
                Next j

                .MoveNext
                i = i + 1
            Wend
        End With
    End If

    'Bind the XArrayDB structure with Grid
    Set o_objGrid.Grid.Array = objArray

    'Find the ADO data type of current column
    eADODataType = adVarChar

    o_objGrid.SetColAlignment 0, vbCenter
    o_objGrid.ApplyFormat

    Enabled = True
0
 
appariCommented:
change this part

   If o_rsData.EOF Then
        objArray.ReDim 0, 0, 0, 0
        o_objGrid.SetNbColumn 0
        'Bind the XArrayDB structure with Grid
        Set o_objGrid.Grid.Array = objArray
        Set o_rsData = Nothing
        Exit Sub
    Else
        objArray.ReDim 0, o_rsData.RecordCount - 1, 0, o_rsData.Fields.Count - 1
        o_objGrid.SetNbColumn o_rsData.Fields.Count
    End If


to


   If o_rsData.EOF Then
        objArray.ReDim 0, -1, 0, o_rsData.Fields.Count - 1

        o_objGrid.SetNbColumn 0
        'Bind the XArrayDB structure with Grid
        Set o_objGrid.Grid.Array = objArray
        Set o_rsData = Nothing
        Exit Sub
    Else
        objArray.ReDim 0, o_rsData.RecordCount - 1, 0, o_rsData.Fields.Count - 1
        o_objGrid.SetNbColumn o_rsData.Fields.Count
    End If


when no data is found always set rows ubound to -1. columns to no of columns in the grid. its working fine on my m/c.

is SetNbColumn is your own method?

0
 
GalliaAuthor Commented:
Thanks it worked.

SetNbColumn is my own. It is used for all the grid (tdbg) in the application.

gallia
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now