Need Help on Ultragrid with VB 6

Posts   
 
    
Beenuxers
User
Posts: 1
Joined: 06-Jun-2006
# Posted on: 06-Jun-2006 08:45:25   

Can someone help me on ultragrid? I need to add row in that grid... I have 3 bands... 1 parent and 2 child... I only allow addnew at band 2... Nah, i have a problem after insert data in the row.... When i clik the other row on the grid there's always error warning cannot insert null to table .... or statement is terminated.. whereas i dont use data binding on my ultragrid...

Here's my codes:


/*** to insert data to the grid... ***/
    rs.Open sql, gConShape, adOpenStatic, adLockPessimistic 
    
    Set rs.ActiveConnection = Nothing
    
    Set UGridPgwas.DataSource = rs
    Set rs = Nothing
    InitGrid

/*** to initialize the grid ***/
Private Sub InitGrid()
    Dim ssCol As SSColumn
    
    UGridPgwas.AddNewBox.Hidden = False
    UGridPgwas.AddNewBox.Prompt = "Untuk Tambah Data -->"
    UGridPgwas.AddNewBox.Style = ssAddNewBoxStyleCompact
    UGridPgwas.UpdateMode = ssUpdateOnUpdate
    UGridPgwas.Override.FetchRows = ssFetchRowsPreloadWithParent

    UGridPgwas.Bands(0).CollapseAll
    UGridPgwas.UpdateMode = ssUpdateOnRowChange
    UGridPgwas.InterBandSpacing = 0
    
    With UGridPgwas.Bands(0)
        .ColHeaderLines = 1
        .AddButtonCaption = " "
        For Each ssCol In .Columns
            ssCol.Hidden = True
        Next
        Set ssCol = Nothing

        With .Override
            .AllowAddNew = ssAllowAddNewNo
            .RowSizing = ssRowSizingAutoFree
            .CellMultiLine = ssCellMultiLineTrue
            .RowSizingArea = ssRowSizingAreaEntireRow
            .HeaderClickAction = ssHeaderClickActionSortMulti
        End With

    With UGridPgwas.Bands(1)
         For Each ssCol In .Columns
            ssCol.Hidden = True
        Next
    End With
    
    With UGridPgwas.Bands(1)
        .ColHeaderLines = 1
        .AddButtonCaption = " "
        For Each ssCol In .Columns
            ssCol.Hidden = True
        Next
        Set ssCol = Nothing
        With .Override
            .AllowAddNew = ssAllowAddNewNo
            .RowSizing = ssRowSizingAutoFree
            .CellMultiLine = ssCellMultiLineTrue
            .RowSizingArea = ssRowSizingAreaEntireRow
            .HeaderClickAction = ssHeaderClickActionSortMulti
        End With
        With .Columns("kdmtk")
            .Header.VisiblePosition = 0
            .Activation = ssActivationActivateNoEdit
            .Width = 810
            .Header.Caption = "Kdmtk"
            .Hidden = False
        End With
        With .Columns("Kelas")
            .Header.VisiblePosition = 1
            .Activation = ssActivationActivateNoEdit
            .Width = 810
            .Header.Caption = "Kelas"
            .Hidden = False
        End With
        With .Columns("jmpst")
            .Header.Caption = "Jml Pst"
            .Header.VisiblePosition = 2
            .Activation = ssActivationActivateNoEdit
            .Width = 810
            .Hidden = False
        End With
    End With

    With UGridPgwas.Bands(2)
        .ColHeaderLines = 1
        .AddButtonCaption = "Tambah &Data"
        .AddButtonToolTipText = "Klik sini untuk tambah row sebelum tambah data"
        For Each ssCol In .Columns
            'ssCol.Hidden = True
            .Hidden = False
        Next
        Set ssCol = Nothing
        With .Override
            .AllowAddNew = ssAllowAddNewYes
            .AllowUpdate = ssAllowUpdateYes
            .RowSizing = ssRowSizingAutoFree
            .CellMultiLine = ssCellMultiLineTrue
            .RowSizingArea = ssRowSizingAreaEntireRow
            .HeaderClickAction = ssHeaderClickActionSortMulti
        End With
        If .Groups.count = 0 Then
            .Groups.Add "PgawsDsn", , "Pengawas Dosen"
            .Groups.Add "PgawsKar", , "Pengawas Karyawan"
            .Groups.Add "PgawsAst", , "Pengawas Asisten"
            .Groups.Add "PgawsOut", , "Pengawas OutSource"
        End If
        
        If Not UGridPgwas.Bands(2).Columns.Exists("pgaws_dsn") Then
            .Columns.Add "pgaws_dsn"
        End If
        With .Columns("pgaws_dsn")
            .Header.VisiblePosition = 1
            .DataType = ssDataTypeChar
            .FieldLen = 5
            .Group = UGridPgwas.Bands(2).Groups("PgawsDsn")
            .Width = 810
            .Header.Caption = "Kode"
            .Hidden = False
        End With
        If Not UGridPgwas.Bands(2).Columns.Exists("nmpgawsdsn") Then
            .Columns.Add "nmpgawsdsn"
        End If
        With .Columns("nmpgawsdsn")
            .Header.VisiblePosition = 2
            .DataType = ssDataTypeText 'ssDataTypeChar
            .FieldLen = 100
            .Activation = ssActivationActivateNoEdit
            .Group = UGridPgwas.Bands(2).Groups("PgawsDsn")
            .Width = 3500
            .Header.Caption = "Nama"
            .Hidden = False
        End With
        With .Columns("remun")
        'With .Columns("stremun_dsn")
            .Header.VisiblePosition = 3
            '.DataType = ssDataTypeText ' ssDataTypeChar
            '.FieldLen = 1
            .Activation = ssActivationActivateNoEdit
            .Group = UGridPgwas.Bands(2).Groups("PgawsDsn")
            .Width = 810
            .Header.Caption = "Remun"
            .Hidden = False
        End With
        If Not UGridPgwas.Bands(2).Columns.Exists("pgaws_kar") Then
            .Columns.Add "pgaws_kar"
        End If
        With .Columns("pgaws_kar")
            .Header.Caption = "Kode"
            .Header.VisiblePosition = 4
            .DataType = ssDataTypeChar
            .FieldLen = 5
            .Group = UGridPgwas.Bands(2).Groups("PgawsKar")
            .Width = 810
            .Hidden = False
        End With
        If Not UGridPgwas.Bands(2).Columns.Exists("nmkar") Then
            .Columns.Add "nmkar"
        End If
        With .Columns("nmkar")
            .Header.VisiblePosition = 5
            .Activation = ssActivationActivateNoEdit
            .DataType = ssDataTypeText
            .FieldLen = 100
            .Group = UGridPgwas.Bands(2).Groups("PgawsKar")
            .Width = 3500
            .Header.Caption = "Nama"
            .Hidden = False
        End With
        If Not UGridPgwas.Bands(2).Columns.Exists("pgaws_ast") Then
            .Columns.Add "pgaws_ast"
        End If
        With .Columns("pgaws_ast")
            .Header.Caption = "Kode"
            .Header.VisiblePosition = 6
            .DataType = ssDataTypeChar
            .FieldLen = 5
            .Group = UGridPgwas.Bands(2).Groups("PgawsAst")
            .Width = 810
            .Hidden = False
        End With
        If Not UGridPgwas.Bands(2).Columns.Exists("nmast") Then
            .Columns.Add "nmast"
        End If
        With .Columns("nmast")
            .Header.VisiblePosition = 7
            .Activation = ssActivationActivateNoEdit
            .DataType = ssDataTypeText
            .FieldLen = 100
            .Width = 3500
            .Header.Caption = "Nama"
            .Group = UGridPgwas.Bands(2).Groups("PgawsAst")
            .Hidden = False
        End With
        If Not UGridPgwas.Bands(2).Columns.Exists("pgaws_out") Then
            .Columns.Add "pgaws_out"
        End If
        With .Columns("pgaws_out")
            .Header.Caption = "Kode"
            .Header.VisiblePosition = 8
            .DataType = ssDataTypeChar
            .FieldLen = 5
            .Group = UGridPgwas.Bands(2).Groups("PgawsOut")
            .Width = 810
            .Hidden = False
        End With
        If Not UGridPgwas.Bands(2).Columns.Exists("nmoutsource") Then
            .Columns.Add "nmoutsource"
        End If
        With .Columns("nmoutsource")
            .Header.VisiblePosition = 9
            .Activation = ssActivationActivateNoEdit
            .DataType = ssDataTypeText
            .FieldLen = 100
            .Group = UGridPgwas.Bands(2).Groups("PgawsOut")
            .Width = 3500
            .Header.Caption = "Nama"
            .Hidden = False
        End With
    End With


Is there something wrong with my code? Thx.. Plz reply me ASAP... simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39797
Joined: 17-Aug-2003
# Posted on: 06-Jun-2006 09:02:11   

Off topic -> General Chat

Frans Bouma | Lead developer LLBLGen Pro