public Delete ( String tableName, String where ) : bool | ||
tableName | String | The table from which to delete. |
where | String | The where clause for the delete. |
return | bool |
/// <summary> /// Handles the Click event of the btnDelete control. Deletes all the specified Team Box Score, as well as any corresponding /// Player Box Scores, from the database. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e"> /// The <see cref="RoutedEventArgs" /> instance containing the event data. /// </param> private void btnDelete_Click(object sender, RoutedEventArgs e) { var r = MessageBox.Show( "Are you sure you want to delete this/these box score(s)?\n" + "This action cannot be undone.\n\n" + "Any changes made to Team Stats by automatically adding this/these box score(s) to them won't be reverted by its deletion.", "NBA Stats Tracker", MessageBoxButton.YesNo); if (r == MessageBoxResult.Yes) { foreach (var bse in dgvBoxScores.SelectedItems.Cast <BoxScoreEntry>().ToList()) { if (bse != null) { var id = bse.BS.ID; _db.Delete("GameResults", "GameID = " + id); _db.Delete("PlayerResults", "GameID = " + id); } _bsHist.Remove(bse); MainWindow.BSHist.Remove(bse); } } }
/** * Handle deleting data. */ public override int Delete(Uri uri, string where, string[] whereArgs) { SQLiteDatabase db = mOpenHelper.GetWritableDatabase(); string constWhere; int count; switch (mUriMatcher.Match(uri)) { case MAIN: // If URI is main table, delete uses incoming where clause and args. count = db.Delete(MainTable.TABLE_NAME, where, whereArgs); break; // If the incoming URI matches a single note ID, does the delete based on the // incoming data, but modifies the where clause to restrict it to the // particular note ID. case MAIN_ID: // If URI is for a particular row ID, delete is based on incoming // data but modified to restrict to the given ID. constWhere = DatabaseUtilsCompat.ConcatenateWhere( IBaseColumnsConstants._ID + " = " + Android_Content.ContentUris.ParseId(uri), where); count = db.Delete(MainTable.TABLE_NAME, constWhere, whereArgs); break; default: throw new System.ArgumentException("Unknown URI " + uri); } GetContext().GetContentResolver().NotifyChange(uri, null); return count; }
public bool deleteUser(string userId, string groupId) { bool success = false; try { mDatabase = mDBHelper.WritableDatabase; beginTransaction(mDatabase); if (!TextUtils.IsEmpty(userId)) { string where = "user_id = ? and group_id = ?"; string[] whereValue = { userId, groupId }; if (mDatabase.Delete(DBHelper.TABLE_FEATURE, where, whereValue) < 0) { return(false); } if (mDatabase.Delete(DBHelper.TABLE_USER, where, whereValue) < 0) { return(false); } setTransactionSuccessful(mDatabase); success = true; } } catch (Java.Lang.Exception) { endTransaction(mDatabase); } return(success); }
public override int Delete(Android.Net.Uri uri, string selection, string[] selectionArgs) { SQLiteDatabase db = dbHelper.WritableDatabase; int count; switch (uriMatcher.Match(uri)) { case LOCATIONS: count = db.Delete(DATABASE_TABLE_NAME, selection, selectionArgs); break; case LOCATION_ID: String locationId = uri.PathSegments.ElementAt(1); string select = ""; if (selection != null) { if (selection.Length > 0) { select = " AND (" + selection + ")"; } } count = db.Delete( DATABASE_TABLE_NAME, _ID + "=" + locationId + select, selectionArgs); break; default: throw new ArgumentException("Unknown URI " + uri); } Context.ContentResolver.NotifyChange(uri, null); return(count); }
public void clearDB(Context context) { dbHelper = new DBHelper(context); SQLiteDatabase db = dbHelper.WritableDatabase; db.Delete("general", null, null); db.Delete("records", null, null); }
public void deleteAll() { SQLiteDatabase db = this.WritableDatabase; db.Delete(DB_TABLE, null, null); db.Close(); }
// delete entry public int deleteData(int id) //deletar { SQLiteDatabase db = this.WritableDatabase; return(db.Delete("Progresso", "id = ? ", new String[] { Convert.ToString(id) })); //esse aqui deixava pre-definidos metodos do sqlite }
//Сюди будемо передавати одиницю, якщо хочемо здійснити запис в базу даних protected override bool RunInBackground(params int[] @params) { int param = @params[0]; if (param == 1) { SQLiteOpenHelper deleteRoomDatabaseHelper = new RationalCleaningDatabaseHelper(myActivity); try { SQLiteDatabase db = deleteRoomDatabaseHelper.WritableDatabase; db.Delete("ROOM_TABLE", "_id = ?", new string[] { roomId.ToString() }); db.Close(); return(true); } catch (SQLException) { return(false); } } return(false); }
public void deleteTask(String task) { SQLiteDatabase db = this.WritableDatabase; db.Delete(DB_TABLE, DB_COLUMN + " = ? ", new string[] { task }); db.Close(); }
public void RemoveTask(String task) { SQLiteDatabase db = this.WritableDatabase; db.Delete(db_table, db_column + " = ?", new string[] { task }); db.Close(); }
public void DeleteTask(String task) { SQLiteDatabase db = this.WritableDatabase; db.Delete(DB_Table, DB_Column + "=?", new String[] { task }); db.Close(); }
/// <summary> /// Удалить сет из локальной БД /// </summary> /// <param name="setIndex"></param> public void DeleteSet(string setName) { SQLiteDatabase db = WritableDatabase; db.Delete(SETS_TABLE_NAME, KEY_SET_NAME + "=?", new string[1] { setName }); }
/// <summary>Handles the Click event of the btnRemove control. Allows the user to remove an item.</summary> /// <param name="sender">The source of the event.</param> /// <param name="e"> /// The <see cref="RoutedEventArgs" /> instance containing the event data. /// </param> private void btnRemove_Click(object sender, RoutedEventArgs e) { if (lstData.SelectedIndex == -1) { return; } var conf = (Conference)lstData.SelectedItem; var r = MessageBox.Show( "Are you sure you want to delete the " + conf.Name + " conference?", "NBA Stats Tracker", MessageBoxButton.YesNo, MessageBoxImage.Question); if (r == MessageBoxResult.No) { return; } var db = new SQLiteDatabase(MainWindow.CurrentDB); MainWindow.Conferences.Remove(conf); db.Delete("Conferences", "ID = " + conf.ID); MainWindow.Divisions.RemoveAll(division => division.ConferenceID == conf.ID); db.Delete("Divisions", "Conference = " + conf.ID); if (MainWindow.Conferences.Count == 0) { MainWindow.Conferences.Add(new Conference { ID = 0, Name = "League" }); db.Insert("Conferences", new Dictionary <string, string> { { "ID", "0" }, { "Name", "League" } }); MainWindow.Divisions.Add(new Division { ID = 0, Name = "League", ConferenceID = 0 }); db.Insert("Divisions", new Dictionary <string, string> { { "ID", "0" }, { "Name", "League" }, { "Conference", "0" } }); } lstData.ItemsSource = null; lstData.ItemsSource = MainWindow.Conferences; TeamStats.CheckForInvalidDivisions(); }
private void button_Click(object sender, RoutedEventArgs e) { var db = new SQLiteDatabase(); String name = label.Content.ToString(); db.Delete("Login", string.Format(" name = '{0}'", name)); }
public override int Delete(AndroidNet.Uri uri, string selection, string[] selectionArgs) { SQLiteDatabase db = this.taskDbHelper.WritableDatabase; int match = sUriMatcher.Match(uri); int deleted = 0; switch (match) { case TASKS: { // Dangerous deleted = db.Delete(TaskContract.TaskEntry.TABLE_NAME, null, null); break; } case TASK_WITH_ID: { // Get the id from the URI string id = uri.PathSegments[1]; // Selection is the _ID column = ? // SelectionArgs is the arg values string mDeletion = TaskContract.TaskEntry.ID + " = ?"; string[] mDeletionArgs = new string[] { id }; deleted = db.Delete(TaskContract.TaskEntry.TABLE_NAME, mDeletion, mDeletionArgs); break; } default: { throw new InvalidOperationException("Unknown uri: " + uri); } } this.Context.ContentResolver.NotifyChange(uri, null); return(deleted); }
/// <summary> /// Удалить канал из локальной БД /// </summary> /// <param name="setIndex"></param> /// <param name="channelName"></param> /// <param name="channelPlatform"></param> public void DeleteChannel(int setIndex, string channelName, DATA.Platforms channelPlatform) { SQLiteDatabase db = WritableDatabase; var strs = new string[3] { channelName, ((int)channelPlatform).ToString(), (setIndex + 1).ToString() }; db.Delete(CHANNELS_TABLE_NAME, KEY_CHANNEL_NAME + "=? and " + KEY_CHANNEL_PLATFORM + "=? and " + KEY_CHANNEL_SET_ID + "=?", strs); }
/** * Execute delete using the current internal state as {@code WHERE} clause. */ public int Delete(SQLiteDatabase db) { AssertTable(); if (LOGV) { Log.Verbose(TAG, "delete() " + this); } return(db.Delete(mTable, GetSelection(), GetSelectionArgs())); }
/// <summary> /// Полностью очистить локальную БД /// </summary> public void ClearDatabase() { SQLiteDatabase db = WritableDatabase; try { db.Delete(SETS_TABLE_NAME, null, null); } catch (Exception) { }; try { db.Delete(CHANNELS_TABLE_NAME, null, null); } catch (Exception) { }; db.ExecSQL("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='" + CHANNELS_TABLE_NAME + "'"); db.ExecSQL("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='" + SETS_TABLE_NAME + "'"); }
private void ButtonRemove_Click(object sender, EventArgs e) { // vars bool found = false; dt = sql.GetDataTable("select * from employees where employeeID=" + TextBoxCardID.Text.Trim() + ";"); // check if this is the card we're looking for if (dt.Rows.Count == 1) { // mark as found found = true; // confirm deletion of card if (MessageBox.Show(this, "Are you sure you want to delete " + dt.Rows[0].ItemArray[1].ToString() + "'s card?\n(Card/Student ID: " + dt.Rows[0].ItemArray[0].ToString() + ")", "Confirm Card Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { // write to file try { sql.Delete("employees", String.Format("employeeID = {0}", dt.Rows[0].ItemArray[0].ToString())); if (CheckBoxDelTimeLog.Checked == true) { sql.Delete("timeStamps", String.Format("employeeID = {0}", dt.Rows[0].ItemArray[0].ToString())); } } catch (Exception err) { MessageBox.Show(this, "There was an error while trying to remove the card.\n\n" + err.Message, "File Deletion Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } // notify user if card wasn't found if (!found) { MessageBox.Show(this, "The card you entered wasn't found. Are you sure you typed it in correctly?", "Card Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Error); } // reset text box TextBoxCardID.Clear(); TextBoxCardID.Focus(); }
//Edição de dados materiais public bool excluirDados(int id) { string idString = id.ToString(); try { db.Delete(ConstantesDB.NOME_TABELA_MATERIAIS, ConstantesDB.ID_MATERIAL + "= ?", new String[] { idString }); return(true); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } return(false); }
private void RemoveOldEntries(List <int> oldFeed, List <int> oldShifts) { string connector = " OR "; //Feed löschen if (oldFeed.Count > 0) { string feed_filter = ""; string feed_attach = ""; foreach (int sql_id in oldFeed) { feed_filter += DatabaseHelper.FEED_TABLE_COL_ID + "='" + sql_id.ToString() + "'" + connector; feed_attach += DatabaseHelper.ATTACH_TABLE_COL_OWNERID + "='" + sql_id.ToString() + "'" + connector; } feed_filter = feed_filter.Substring(0, feed_filter.Length - connector.Length); feed_attach = feed_attach.Substring(0, feed_attach.Length - connector.Length); database.Delete(DatabaseHelper.FEED_TABLE, feed_filter, null); database.Delete(DatabaseHelper.ATTACH_TABLE, feed_attach + " AND " + DatabaseHelper.ATTACH_TABLE_COL_OWNER + "=" + "'" + DatabaseHelper.OWNER_FEED + "'", null); } //Shifts löschen if (oldShifts.Count > 0) { string shifts_filter = ""; string shifts_attach = ""; foreach (int sql_id in oldShifts) { shifts_filter += DatabaseHelper.SHIFT_TABLE_COL_ID + "='" + sql_id.ToString() + "'" + connector; shifts_attach += DatabaseHelper.ATTACH_TABLE_COL_OWNERID + "='" + sql_id.ToString() + "'" + connector; } shifts_filter = shifts_filter.Substring(0, shifts_filter.Length - connector.Length); shifts_attach = shifts_attach.Substring(0, shifts_attach.Length - connector.Length); database.Delete(DatabaseHelper.SHIFT_TABLE, shifts_filter, null); database.Delete(DatabaseHelper.ATTACH_TABLE, shifts_attach + " AND " + DatabaseHelper.ATTACH_TABLE_COL_OWNER + "='" + DatabaseHelper.OWNER_SHIFTS + "'", null); } }
public int Delete(String name) { try { SQLiteDatabase db1 = helper.WritableDatabase; String[] whereArgs = { name }; int count = db1.Delete(Constants.TB_NAME, Constants.NAME + "=?", whereArgs); return(count); } catch (Exception e) { String s2 = e.Message; MainActivity1 m1 = new MainActivity1(); Toast.MakeText(m1, "Error thrown" + " " + s2, ToastLength.Long).Show(); } return(0); }
private void DeleteButton_Click(object sender, EventArgs e) { try { string toDeleteId = AvgHoursGridView.SelectedRows[0].Cells[0].Value.ToString(); int rowId = AvgHoursGridView.SelectedRows[0].Index; if (sql.Delete("avgHours", "id=" + toDeleteId)) { DisableUI(); AvgHoursGridView.RowStateChanged -= new DataGridViewRowStateChangedEventHandler(AvgHoursGridView_RowStateChanged); AvgHoursGridView.Rows.RemoveAt(rowId); AvgHoursGridView.RowStateChanged += new DataGridViewRowStateChangedEventHandler(AvgHoursGridView_RowStateChanged); SetAddButton(); } } catch (Exception err) { MessageBox.Show(this, "There was an error while trying to delete the entry.\n\n" + err.Message, "Delete Avg Hours Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DeleteButton_Click(object sender, EventArgs e) { try { string toDeleteId = DataGridViewTimes.SelectedRows[0].Cells[2].Value.ToString(); int rowId = DataGridViewTimes.SelectedRows[0].Index; if (sql.Delete("timeStamps", "id=" + toDeleteId)) { DataGridViewTimes.RowStateChanged -= new System.Windows.Forms.DataGridViewRowStateChangedEventHandler(DataGridViewTimes_RowStateChanged); DataGridViewTimes.Rows.RemoveAt(rowId); DataGridViewTimes.RowStateChanged += new System.Windows.Forms.DataGridViewRowStateChangedEventHandler(DataGridViewTimes_RowStateChanged); DisableUI(); DisableTimePickers(); } } catch (Exception err) { MessageBox.Show(this, "There was an error while trying to delete the entry.\n\n" + err.Message, "Delete Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void DeleteImageInfoEntry(Context context, long dbImgRowId) { lock (this) { using (DbHelper dbHelper = new DbHelper(context)) using (SQLiteDatabase db = dbHelper.WritableDatabase) { StringBuilder sb = new StringBuilder(); sb.Append(DbContract.ImageInfoEntry._ID) .Append("=") .Append(dbImgRowId); db.Delete(DbContract.ImageInfoEntry.TABLE_NAME, sb.ToString(), null); dbHelper.Close(); } } }
//Delete Existing contact public void DeleteUser(string Id) { if (Id == null) { return; } //Obtain writable database SQLiteDatabase db = this.WritableDatabase; ICursor cursor = db.Query("User", new String[] { "Id", "Firstname", "Lastname", "Address", "Email" }, "Id=?", new string[] { Id }, null, null, null, null); if (cursor != null) { if (cursor.MoveToFirst()) { // update the row db.Delete("User", "Id=?", new String[] { cursor.GetString(0) }); } cursor.Close(); } }
//Delete Existing contact public void DeleteInfoMedica(string infoMedicaId) { if (infoMedicaId == null) { return; } //Obtain writable database SQLiteDatabase db = this.WritableDatabase; ICursor cursor = db.Query("InfoMedica", new String[] { "id", "idPersona", "identificacion", "peso", "altura", "presionArterial", "frecuenciaCardiaca", "detalle" }, "id=?", new string[] { infoMedicaId }, null, null, null, null); if (cursor != null) { if (cursor.MoveToFirst()) { // update the row db.Delete("InfoMedica", "id=?", new String[] { cursor.GetString(0) }); } cursor.Close(); } }
public bool RemoveCollectionItem(CollectionItemList list) { string selection = CollectionItemList.KEY_COLLECTION_ID + " = ? AND " + CollectionItemList.KEY_MOVIE_ID + " = ?"; string[] selectionArg = new string[] { list.CollectionID.ToString(), list.MovieID.ToString() }; try { int deleted = mDB.Delete(CollectionItemList.TABLE_NAME, selection, selectionArg); if (deleted > 0) { if (CollectionItemListObserver != null) { foreach (CollectionItemListLoader observer in CollectionItemListObserver) { observer.OnContentChanged(); } } return(true); } else { return(false); } } catch (SQLException ex) { Toast.MakeText(Application.Context, ex.Message, ToastLength.Long).Show(); return(false); } }
//Delete Existing auto public void DeleteAuto(string autoId) { if (autoId == null) { return; } //Obtain writable database SQLiteDatabase db = this.WritableDatabase; ICursor cursor = db.Query("Vehicle", new String[] { "Id", "Year", "Make", "Model", "Color", "Description", "PercentagePaint", "PercentageBody", "PercentageGlass", "PercentageTrim", "PercentageUpholstery", "PercentageMechanical", "PercentageElectrical", "PercentageFrame", "PercentageTires", "PercentageOverall" }, "Id=?", new string[] { autoId }, null, null, null, null); if (cursor != null) { if (cursor.MoveToFirst()) { // update the row db.Delete("Vehicle", "Id=?", new String[] { cursor.GetString(0) }); } cursor.Close(); } }
//Delete Existing contact public void DeletePersona(string personaId) { if (personaId == null) { return; } //Obtain writable database SQLiteDatabase db = this.WritableDatabase; ICursor cursor = db.Query("Persona", new String[] { "id", "identificacion", "nombre", "apellidos", "direccion", "correo", "telefono", "fechaNac", "sexo", "estadoCivil", "tipoSangre", "detalle" }, "id=?", new string[] { personaId }, null, null, null, null); if (cursor != null) { if (cursor.MoveToFirst()) { // update the row db.Delete("Persona", "id=?", new String[] { cursor.GetString(0) }); } cursor.Close(); } }
private void ConfirmDeleteProfile() { try { //Delete from Database db = new SQLiteDatabase(); db.Delete("profileList", String.Format("profilName = '{0}'", profileSelected.ProfilName)); loginDataView.ServersProfiles.Remove(profileSelected); this.profileSelected = null; NotifyBox.Show( (DrawingImage)this.FindResource("SearchDrawingImage"), "Profil Manager", "Profil supprimé avec succès !", false); } catch (Exception e) { MessageDialog.ShowAsync( "Exception !", "Problème lors de la suppression du profil selectionné, annulation !", MessageBoxButton.OK, MessageDialogType.Light, this); Logger.ExceptionLogger.Error("Attempt to delete from database error : " + profileSelected.ToString() + "\n" + e.ToString()); } }
public void TestSQLiteDBDelete() { db = new SQLiteDatabase(); int id = 1; try { db.Delete("colors", String.Format("colors.id={0}", id)); } catch (Exception ex) { Console.WriteLine(ex.Message); } }