11 Replies - 1727 Views - Last Post: 27 September 2011 - 02:44 AM Rate Topic: -----

#1 saren  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 12-January 11

error in delete * from table1

Posted 05 September 2011 - 09:06 AM

i don't know why this is happening in my program..
i want to delete all files in my database, but i have errors,

this is my code
 Adodc1.RecordSource = "delete * from table1"
Adodc1.Refresh



and then when i start clicking it an error appears

adodc1
Operation is not allowed when the object is closed.

and then

Run-time error '3704':
Application-defined or object-defined error

but it still works to delete all the files, but how can i do it without errors?

Is This A Good Question/Topic? 0
  • +

Replies To: error in delete * from table1

#2 Patric  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 27-July 09

Re: error in delete * from table1

Posted 05 September 2011 - 06:26 PM

I think you haven reset Adodc1 after closing it somewhere else?

Set Adodc1 = New YourComponent


Put it before your
Adodc1.RecordSource = "delete * from table1" 
Adodc1.Refresh

This post has been edited by Patric: 05 September 2011 - 06:27 PM

Was This Post Helpful? 0
  • +
  • -

#3 saren  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 12-January 11

Re: error in delete * from table1

Posted 06 September 2011 - 06:03 AM

ahmm sir patric, i have an error in that code?

and besides i don't know what's the meaning of your code or how that code runs :(

what's the reset adodc by the way?
sorry newbie :|
Was This Post Helpful? -1
  • +
  • -

#4 Patric  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 27-July 09

Re: error in delete * from table1

Posted 06 September 2011 - 05:18 PM

Don't call me sir, i'm newbie too :sweatdrop:
Let's learn together :sorcerer:

My bad, i misunderstood your ADODC to the ADODB that i always use. :sweatdrop:

Anyway, i found this ADO tutorial, hope it could help
Visual Basic & ADO Tutorial
Was This Post Helpful? 0
  • +
  • -

#5 whocares?  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 10
  • Joined: 08-September 11

Re: error in delete * from table1

Posted 09 September 2011 - 01:07 AM

Delete * From table1 will not work i think because the syntax for deleting everything in a table as far as i remember is
DELETE FROM table1

Was This Post Helpful? 2
  • +
  • -

#6 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,796
  • Joined: 26-March 09

Re: error in delete * from table1

Posted 09 September 2011 - 04:38 AM

whocares? you're correct, the syntax is
delete from table1

Was This Post Helpful? 0
  • +
  • -

#7 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: error in delete * from table1

Posted 09 September 2011 - 11:29 PM

Actually, the alternative syntax with the * is acceptable in Access. I just looked it up. :) Don't know if the op is using access or not tho.

saren, patric is right in that he is telling you that you have closed your recordset. Once you delete all the records from a recordset, it stands to reason that it will get closed.

You don't tell us the line that causes the error. But I would suggest that you check your logic. Why do you want to keep deleting all the records from a recordset after it's empty? No wonder you're getting errors.
Was This Post Helpful? 0
  • +
  • -

#8 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,796
  • Joined: 26-March 09

Re: error in delete * from table1

Posted 10 September 2011 - 08:26 AM

View PostBobRodes, on 10 September 2011 - 12:29 AM, said:

Actually, the alternative syntax with the * is acceptable in Access. I just looked it up. :) Don't know if the op is using access or not tho.

saren, patric is right in that he is telling you that you have closed your recordset. Once you delete all the records from a recordset, it stands to reason that it will get closed.

You don't tell us the line that causes the error. But I would suggest that you check your logic. Why do you want to keep deleting all the records from a recordset after it's empty? No wonder you're getting errors.


I stand corrected....not familiar with SQL in Access! :(
Was This Post Helpful? 0
  • +
  • -

#9 saren  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 12-January 11

Re: error in delete * from table1

Posted 15 September 2011 - 08:44 AM

@all thank you for posting your replies here,

but i think the code:
Adodc1.RecordSource = "DELETE FROM table1"
Adodc1.Refresh



and my code
Adodc1.RecordSource = "delete * from table1"
adodc1.Refresh



is definitely the same right?
or i just misunderstood that codes?

because the same error occurs..

adodc1
Operation is not allowed when the object is closed.

and then

Run-time error '3704':
Application-defined or object-defined error

btw sir bob the error line is pointed at
Adodc1.Refresh


This post has been edited by saren: 15 September 2011 - 08:45 AM

Was This Post Helpful? 1
  • +
  • -

#10 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: error in delete * from table1

Posted 16 September 2011 - 03:50 PM

Have a look at this: http://www.xtremevbt...ad.php?t=199263 and let us know what you come up with.
Was This Post Helpful? 0
  • +
  • -

#11 moikzz214  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 06-September 11

Re: error in delete * from table1

Posted 27 September 2011 - 12:44 AM

Dim SQL As String
SQL = "Delete from Tablename;"
db.Execute (SQL)

db is my database connection and im using DAO
but maybe they are similar to adodc
Was This Post Helpful? 0
  • +
  • -

#12 chkm8  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 84
  • Joined: 24-December 08

Re: error in delete * from table1

Posted 27 September 2011 - 02:44 AM

I've used the adodc 2 years ago, try this code Adodc1.Recordset.Delete instead of your code., of course you should select a data in your datagrid,,
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1