ADO & gridControl


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: ADO & gridControl

  1. #1
    Pam Guest

    ADO & gridControl


    How do you avoid getting an error when you cancel an addNew? The grid is
    adding a blank record to the record set.

  2. #2
    Tim Guest

    Re: ADO & gridControl

    I have included a function that uses transactions. You could do something
    like this in your grid...if its ADO


    Public Function PutRS(RS As ADODB.Recordset) As Boolean
    'USE THIS TO UPDATE A RECORDSET IN BATCH (TRANSACTIONAL) 'MODE IF CHANGES TO
    THE RECORDSET'S WERE MADE PRIOR TO 'THIS CALL 'THIS FUNCTION WILL COMMIT THEM
    TO THE 'UNDERYLING DATABASE


    On Error GoTo LocalError
    PutRS = False
    If EmptyRS(RS) Then
    Exit Function
    ElseIf RS.LockType = adLockReadOnly Then
    Exit Function
    Else
    Dim cn As New ADODB.Connection
    With cn
    .ConnectionString = ConnectionString
    .CursorLocation = adUseServer
    .Open
    .BeginTrans
    End With
    With RS
    .ActiveConnection = cn
    .UpdateBatch
    cn.CommitTrans
    Set .ActiveConnection = Nothing
    End With
    cn.Close
    Set cn = Nothing
    End If
    PutRS = True
    Exit Function
    LocalError:
    m_sLastError = Err.Number & " - " & Err.Description
    If cn.State = adStateOpen Then
    cn.RollbackTrans
    cn.Close
    End If
    Set cn = Nothing
    PutRS = False
    End Function

    Pam wrote:

    > How do you avoid getting an error when you cancel an addNew? The grid is
    > adding a blank record to the record set.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center