adding clear command to impluse database source

09/02/2013 13:05 zoro7070#1
iam trying to add clear command to impluse mysql system to delete all content from a table here is my try
Code:
public MySqlCommand Clear(string table)
        {
            _command = new StringBuilder("DELETE FROM <R>");
            return this;
        }
Code:
public enum MySqlCommandType
    {
        DELETE, INSERT, SELECT, UPDATE, COUNT, CLEAR
    }
when i use it nothing happened at all
Code:
MySqlCommand cmd = new MySqlCommand(MySqlCommandType.CLEAR);
                cmd.Clear("tradelog");
:confused:
09/02/2013 13:08 shadowman123#2
why would i code smthing thats already coded use smthing like that

Code:
new MySqlCommand(MySqlCommandType.DELETE).Delete("GuildAdvertisment", "GuildID", guild.ID).Execute();
GuildAdvertisment is the Table that im going to delete Entries From
Delete is going to be Through Checking GuildID Column if it has value equals to guild.ID then Remove the Line .. its pretty easy to use

btw your code wont work as you forgot to use .Execute method
09/02/2013 13:49 zoro7070#3
Quote:
Originally Posted by shadowman123 View Post
why would i code smthing thats already coded use smthing like that

Code:
new MySqlCommand(MySqlCommandType.DELETE).Delete("GuildAdvertisment", "GuildID", guild.ID).Execute();
GuildAdvertisment is the Table that im going to delete Entries From
Delete is going to be Through Checking GuildID Column if it has value equals to guild.ID then Remove the Line .. its pretty easy to use

btw your code wont work as you forgot to use .Execute method
you are right about the delete command and .Execute method i will try with it.
i do that to clear some database tables content every 3 days with simple code and because some of this table doesn't have value in the source like my download table and other so here we are ;)...
09/02/2013 13:54 shadowman123#4
In my point of View you shouldnt add Tables that u rnt going to use .. like Trade Log why would i make smthing like that .. its not important and if it is you can add it in Text so it doesnt make the Database laggy and beside that u arent going to Read data from that tradelog Table so Remove it
09/02/2013 14:17 zoro7070#5
Quote:
Originally Posted by shadowman123 View Post
In my point of View you shouldnt add Tables that u rnt going to use .. like Trade Log why would i make smthing like that .. its not important and if it is you can add it in Text so it doesnt make the Database laggy and beside that u arent going to Read data from that tradelog Table so Remove it
i don't recommend useless table too but its a some kind of private server for my friends and i want to make sure that no one is cheating and for text files too because of size of the data
09/02/2013 14:26 shadowman123#6
1st : its already useless ... who ever gives his account to any1 Deserve to be Robbed away from his Gears , Money or w.e and they created Locking Gear for A reason

2nd : the text file wont consume much space .. beside that you can delete it every 3 days :) and its much more clear than in database which means its better in reading
09/02/2013 15:12 Super Aids#7
You forgot to call Execute().
09/09/2013 11:18 zoro7070#8
thanks @shadowman123 @Super Aids
02/12/2014 11:16 martoon#9
I know this is an old post, but for others who is looking for this...

Replace:
Quote:
public enum MySqlCommandType
{
DELETE, INSERT, SELECT, UPDATE, COUNT, CLEAR
}
Insert:
Quote:
#region Clear
public MySqlCommand Clear(string table)
{
_command = _command.Replace("<R>", "`" + table + "`");
return this;
}
#endregion
And this to the switch (Type)
Quote:
case MySqlCommandType.CLEAR:
{
_command = new StringBuilder("DELETE FROM <R>");
break;
}