How do I delete all tables in a database using SqlCommand?

Posted by mafutrct on Stack Overflow See other posts from Stack Overflow or by mafutrct
Published on 2010-04-08T10:35:14Z Indexed on 2010/04/08 11:03 UTC
Read the original article Hit count: 237

Filed under:
|

Unlike the other posts about the task "delete all tables", this question is specifically about using SqlCommand to access the database.

A coworker is facing the problem that no matter how it attempts it, he can't delete all tables from a database via SqlCommand. He states that he can't perform such action as long as there is an active connection - the connection by the SqlCommand itself.

I believe this should be possible and easy, but I don't have much of a clue about databases so I came here to ask. It would be awesome if you could provide a short code example in C# (or any .NET language, for that matter).

If you require additional information, just leave a comment.

© Stack Overflow or respective owner

Related posts about sqlcommand

Related posts about database