473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Error Deleting Table from Access DB

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.a spx Line:
31

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

System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult) +154
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult)
+92
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior,
Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(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.a spx: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

Nov 19 '05 #1
1 1499
> delCmd = "DELETE * FROM ORDERS"

This looks like an SQL command to delete all rows from the orders table
(not the orders table itself.) The proper syntax is without the *:

DELETE FROM ORDERS

If you would rather delete a single order only, try something like:

DELETE FROM ORDERS WHERE ORDERNR = 'MyOrderNumber'

Greetings,
Wessel
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mark | last post by:
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...
4
by: Mark | last post by:
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...
1
by: Mark | last post by:
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...
1
by: sphinney | last post by:
All, I'm not sure how to adequately explain my problem in two sentences or less, so at the risk of providing TMI, here's the condensed verion. I have developed an Access 2002 database file that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.