Error Message when deleting a file from Access Database

Discussion in 'ASP General' started by Mark, Apr 18, 2005.

  1. Mark

    Mark Guest

    Not sure this is the right place for this questions, but here goes:

    I get an error message when deleting an table from a Access database.

    The code is as follows and the error message is after it.


    ***************** Start Code ********************
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Data.Oledb" %>

    Sub Page_Load(Sender as object, e as EventArgs)
    if not isPostBack then
    '************* Delete previous orders ********
    Dim Con As OleDbConnection = New OleDbConnection
    Dim DA As OleDbDataAdapter = New OleDbDataAdapter
    Dim ConnectString, delCmd, x as String

    x = Server.Mappath("\ASPClass\FinalProj\DB.mdb")

    ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & x

    Con.ConnectionString = ConnectString


    delCmd = "DELETE * FROM ORDERS"

    DA.DeleteCommand = New OleDbCommand(delCmd, Con)
    Con.Open
    DA.DeleteCommand.ExecuteNonQuery()
    '*********************************************
    end if
    End Sub
    ******************** End Code ********************

    ******************** Start Error Message *****************
    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    Could not delete from specified tables.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information about
    the error and where it originated in the code.

    Exception Details: System.Data.OleDb.OleDbException: Could not delete from
    specified tables.

    Source Error:


    Line 29: DA.DeleteCommand = New OleDbCommand(delCmd, Con)
    Line 30: Con.Open
    Line 31: DA.DeleteCommand.ExecuteNonQuery()
    Line 32: '************************************
    Line 33: end if


    Source File: c:\inetpub\wwwroot\ASPClass\FinalProj\ShopSignIn.aspx Line:
    31

    Stack Trace:


    [OleDbException (0x80004005): Could not delete from specified tables.]
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
    +41

    System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
    dbParams, Object& executeResult) +154
    System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
    +92
    System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
    Object& executeResult) +65
    System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
    behavior, String method) +112
    System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +54
    ASP.ShopSignIn_aspx.Page_Load(Object Sender, EventArgs e) in
    c:\inetpub\wwwroot\ASPClass\FinalProj\ShopSignIn.aspx:31
    System.Web.UI.Control.OnLoad(EventArgs e) +67
    System.Web.UI.Control.LoadRecursive() +29
    System.Web.UI.Page.ProcessRequestMain() +742


    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:1.0.3705.6018; ASP.NET
    Version:1.0.3705.6018

    ******************** End Error Message *********************


    Thank you for your help.

    Mark
     
    Mark, Apr 18, 2005
    #1
    1. Advertising

  2. "Mark" <> wrote in message
    news:...
    > Not sure this is the right place for this questions, but here goes:
    >
    > I get an error message when deleting an table from a Access database.


    This is .net code, so you should be asking in a .net group. They have
    "aspnet" in their names.

    But, before doing that, make sure your aspnet account has NTFS permissions
    to modify the directory that your MDB file exists in.

    Also, it's not "DELETE * FROM table..." It's just "DELETE FROM TABLE....

    Ray at work
     
    Ray Costanzo [MVP], Apr 18, 2005
    #2
    1. Advertising

  3. Ray Costanzo [MVP] wrote:
    > "Mark" <> wrote in message
    > news:...
    >> Not sure this is the right place for this questions, but here goes:
    >>
    >> I get an error message when deleting an table from a Access database.

    >
    > This is .net code, so you should be asking in a .net group. They have
    > "aspnet" in their names.
    >
    > But, before doing that, make sure your aspnet account has NTFS
    > permissions to modify the directory that your MDB file exists in.
    >
    > Also, it's not "DELETE * FROM table..." It's just "DELETE FROM
    > TABLE....
    >

    :)
    Not with Access ... the * is required in JetSQL.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Apr 18, 2005
    #3
  4. "Bob Barrows [MVP]" <> wrote in message
    news:...
    > >
    > > Also, it's not "DELETE * FROM table..." It's just "DELETE FROM
    > > TABLE....
    > >

    > :)
    > Not with Access ... the * is required in JetSQL.



    I thought that was only the case with MDAC2.5 and older or something like
    that. I believe the more recent versions of Jet are cool with not using the
    *.

    Ray at work
     
    Ray Costanzo [MVP], Apr 18, 2005
    #4
  5. Ray Costanzo [MVP] wrote:
    > "Bob Barrows [MVP]" <> wrote in message
    > news:...
    >>>
    >>> Also, it's not "DELETE * FROM table..." It's just "DELETE FROM
    >>> TABLE....
    >>>

    >> :)
    >> Not with Access ... the * is required in JetSQL.

    >
    >
    > I thought that was only the case with MDAC2.5 and older or something
    > like that. I believe the more recent versions of Jet are cool with
    > not using the *.
    >

    Really? I'll have to try that ... yes, I guess you're right. But the * still
    works fine.

    Bob
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Apr 18, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWFyaw==?=

    Error Deleting Table from Access DB

    =?Utf-8?B?TWFyaw==?=, Apr 20, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,838
    Wessel Troost
    Apr 20, 2005
  2. Luis Esteban Valencia Muñoz
    Replies:
    3
    Views:
    1,432
    Scott Allen
    Jun 4, 2005
  3. Harry Barker
    Replies:
    2
    Views:
    536
    Alf P. Steinbach
    Apr 19, 2006
  4. Ahmed, Shakir

    Deleting Microsoft access database

    Ahmed, Shakir, Mar 20, 2008, in forum: Python
    Replies:
    1
    Views:
    301
    sturlamolden
    Mar 20, 2008
  5. crea
    Replies:
    2
    Views:
    427
    Nobody
    Dec 28, 2012
Loading...

Share This Page