locked
Cannot delete from Access database RRS feed

  • Question

  • User-775831949 posted

    I have a code like this to delete all data in table:-

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            AccessDataSource1.Delete()
            
    End Sub 

    <asp:AccessDataSource ID="AccessDataSource1" runat="server"
            DataFile="~/Data.mdb"
            DeleteCommand="DELETE * FROM [Table1]" 
           >
            
        </asp:AccessDataSource>

    I get this error: System.Data.OleDb.OleDbException: Could not delete from specified tables

    For same connection add record is ok, only delete get error. What is wrong with my code ?

    Also if I run this SQL DELETE * FROM [Table1] within Access there is no error.

    Pls help

     

    Monday, January 17, 2011 4:36 AM

Answers

  • User1867929564 posted

    write only,
    DELETE  FROM [Table1]

    also check if you hv created any constraint.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 18, 2011 1:59 AM

All replies

  • User-693248168 posted

    Does your table has any foreign key?



    Monday, January 17, 2011 11:31 AM
  • User1867929564 posted

    write only,
    DELETE  FROM [Table1]

    also check if you hv created any constraint.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 18, 2011 1:59 AM