0

Right now, I have a simple web application that displays the entries of a database. One of the fields that is visible in the database is a bool?, which is true, false, or neither. Everything in the database originally should have the bool? set to neither.

Here's what I want to get working: when a user edits an entry in the table by selecting either true or false for the bool? field, I want to be able to run some C# code (that I have already written) and have that entry deleted from the database. This means that the next time that the database is loaded, once again all the entries will have neither true nor false selected in the bool? field.

Does someone know how I can do this simply? (I know very little about querying databases or creating web apps in general.)

6
  • What type of database are you using? Commented Jul 30, 2012 at 17:57
  • 1
    "MVC3" + "CRUD" should give you what you want. Here is an example: codeproject.com/Articles/277576/… Commented Jul 30, 2012 at 17:58
  • What have you tried? Commented Jul 30, 2012 at 18:01
  • DELETE FROM TABLE WHERE BOOLFIELD = 1 ??? Commented Jul 30, 2012 at 18:02
  • @ErikPhilips: It would be more polite to at least ask him to post some code first. He has stated that there is a "simple web application" in place. Commented Jul 30, 2012 at 18:10

2 Answers 2

1

My problem was less about how to delete the items and more about how to pick out from the database those chosen to be deleted.

I found that this does the trick:

var toBeRemoved = from m in db.Issues
                           where m.Remove.HasValue && m.Remove
                           select m;
Sign up to request clarification or add additional context in comments.

Comments

0

I believe when you say "true, false, or neither", the neither means null in the database, so, without seeing your code, I believe you could change the SELECT that retrieves the rows for the view to display, to have a WHERE *field* IS NULL in it. If this doesn't help, please post us some control, view, and model code.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.