SQLiteDatabase.ClearTable C# (CSharp) Method

ClearTable() public method

Allows the user to easily clear all data from a specific table.
public ClearTable ( String table ) : bool
table String The name of the table to clear.
return bool
    public bool ClearTable(String table)
    {
        try
        {

            this.ExecuteNonQuery(String.Format("delete from {0};", table));
            return true;
        }
        catch
        {
            return false;
        }
    }

Usage Example

Example #1
0
        static void Main()
        {
            //Needed for log4net to read from the app.config
            XmlConfigurator.Configure();

            var db = new SQLiteDatabase(@"D:\Fun\Code\GitHub\Logger\Database\MyLogs.db;");
            //Clearing previous test data
            db.ClearTable("Log");

            AddFakeData();
            RetrieveAndDisplayData(db);
        }