Cannot Delete a row in a datagrid 
Author Message
 Cannot Delete a row in a datagrid

To whom it may help me:

Hi there,
I am really having problems to delete a record from a datagrid. I have done
in other form and try to keep as equal as possible. It does not work in this
case.

When the 'recordaux.Delete' and 'recordaux.Update' sentences execute, the
following messages appear:

'A given HROW referred to a hard- or soft-deleted row'

Then

'Insufficient base table information for updating or refreshing'

The result:
Nothing is deleted.

I really appreciate if someone can help me to solve this problem or provide
an alternate solution!!!

Thanks in advance

Leopoldo

Here's the code !

Private Sub Form_Load()

    Dim qrystr As String
    Dim emp_aux As Integer

    ' Reading Employees
    Set recordaux = New Recordset
    recordaux.Open "SELECT DPS_EMPLOYEES.CEMPLOYEE,
DPS_EMPLOYEES.XLASTNAME,DPS_EMPLOYEES.XFIRSTNAME
                                    From DPS_EMPLOYEES WHERE
DPS_EMPLOYEES.BACTIVE = 'T'AND DPS_EMPLOYEES.BDUMMY = 'T';",
                                    connDPMSdb, adOpenDynamic,
adLockOptimistic

    Set DataGrid.DataSource = recordaux

    'So far so good
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button _

    On Error Resume Next
    Select Case Button.Key
        Case "DeleteRecord"
               connDPMSdb.Errors.Clear
               On Error GoTo handling
                'Here comes the problem
                recordaux.Delete
                recordaux.Update

                'Refreshing the grid
                Set DataGrid.DataSource = Nothing

                ' Reading Employees
                Set recordaux = New Recordset
                recordaux.Open "SELECT DPS_EMPLOYEES.CEMPLOYEE,
DPS_EMPLOYEES.XLASTNAME,
                                                DPS_EMPLOYEES.XFIRSTNAME
From DPS_EMPLOYEES WHERE DPS_EMPLOYEES.BACTIVE = 'T'AND
                                                DPS_EMPLOYEES.BDUMMY = 'T';"
, connDPMSdb, adOpenDynamic, adLockOptimistic

                Set DataGrid.DataSource = recordaux

        Case "Accept"
            Unload Me
    End Select
handling:
    MsgBox "Error:" + CStr(Err.Number) + vbCrLf + Err.Description

End Sub



Mon, 16 Jun 2003 02:19:50 GMT  
 Cannot Delete a row in a datagrid
You won't be able to do the update or delete if there is insufficient
information in the row to uniquely identify that row. Try adding the primary
key for the table to the select statement. If that causes the update/delete
to function, then you know what the problem was.
regards,
ed

Quote:
> To whom it may help me:

> Hi there,
> I am really having problems to delete a record from a datagrid. I have
done
> in other form and try to keep as equal as possible. It does not work in
this
> case.

> When the 'recordaux.Delete' and 'recordaux.Update' sentences execute, the
> following messages appear:

> 'A given HROW referred to a hard- or soft-deleted row'

> Then

> 'Insufficient base table information for updating or refreshing'

> The result:
> Nothing is deleted.

> I really appreciate if someone can help me to solve this problem or
provide
> an alternate solution!!!

> Thanks in advance

> Leopoldo

> Here's the code !

> Private Sub Form_Load()

>     Dim qrystr As String
>     Dim emp_aux As Integer

>     ' Reading Employees
>     Set recordaux = New Recordset
>     recordaux.Open "SELECT DPS_EMPLOYEES.CEMPLOYEE,
> DPS_EMPLOYEES.XLASTNAME,DPS_EMPLOYEES.XFIRSTNAME
>                                     From DPS_EMPLOYEES WHERE
> DPS_EMPLOYEES.BACTIVE = 'T'AND DPS_EMPLOYEES.BDUMMY = 'T';",
>                                     connDPMSdb, adOpenDynamic,
> adLockOptimistic

>     Set DataGrid.DataSource = recordaux

>     'So far so good
> End Sub

> Private Sub Toolbar1_ButtonClick(ByVal Button _

>     On Error Resume Next
>     Select Case Button.Key
>         Case "DeleteRecord"
>                connDPMSdb.Errors.Clear
>                On Error GoTo handling
>                 'Here comes the problem
>                 recordaux.Delete
>                 recordaux.Update

>                 'Refreshing the grid
>                 Set DataGrid.DataSource = Nothing

>                 ' Reading Employees
>                 Set recordaux = New Recordset
>                 recordaux.Open "SELECT DPS_EMPLOYEES.CEMPLOYEE,
> DPS_EMPLOYEES.XLASTNAME,
>                                                 DPS_EMPLOYEES.XFIRSTNAME
> From DPS_EMPLOYEES WHERE DPS_EMPLOYEES.BACTIVE = 'T'AND
>                                                 DPS_EMPLOYEES.BDUMMY =
'T';"
> , connDPMSdb, adOpenDynamic, adLockOptimistic

>                 Set DataGrid.DataSource = recordaux

>         Case "Accept"
>             Unload Me
>     End Select
> handling:
>     MsgBox "Error:" + CStr(Err.Number) + vbCrLf + Err.Description

> End Sub



Mon, 16 Jun 2003 10:21:49 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Cannot delete rows in SQL attached table

2. DataGrid - Row cannot be located for updating

3. DataGrid: empty row cannot be inserted errors...

4. How to delete a row in a datagrid.

5. Delete a row in a Datagrid using VB.net

6. DataGrid row delete

7. How to delete row from datagrid

8. Datagrids, DataSets and deleting Rows

9. DataGrid: how to handle deleted rows

10. Delete a row from datagrid

11. Disable Delete row function in Datagrid

12. Delete Row in Datagrid

 

 
Powered by phpBB® Forum Software