July 19th, 2005, 01:19 PM
Join Date: Jul 2005
Time spent in forums: 30 m 55 sec
Reputation Power: 0
how to delete a table from MS ACCESS database from asp.net using VB.net
I am trying to develop a web application in asp.net where my database is in MS ACCESS.
Dim conn As OleDbConnection
Dim mycommand As OleDbCommand
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\CBPCleanData\Result File\" & tname
conn = New OleDbConnection(connString)
mycommand = New OleDbCommand("delete * from cbp_prest2", conn)
mycommand.CommandText = "delete * from cbp_prest3"
mycommand.CommandText = "delete * from cbp_prest4"
mycommand.CommandText = ("delete * from cbp_prest4_sic")
when I used the above code I am getting the following error.
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.
Line 13: mycommand = New OleDbCommand("delete * from cbp_prest2", conn)
Line 14: mycommand.ExecuteNonQuery()
Line 15: mycommand.CommandText = "delete * from cbp_prest3"
Line 16: mycommand.ExecuteNonQuery()
Source File: c:\inetpub\wwwroot\CBPApplication\WebForm1.aspx.vb Line: 14
I am new to .net programming. Can anyone help me to overcome this problem.