1

I have an access database that I created using sql in the actual program and have used a 'BIT' to make a record true or false. Now I would like to use the update sql statement to change whether my record is true or false.

For example I have a payments database table and a paid record which is either true or false.

if (HasPaidCBOX.Checked)
{
    Cmd.CommandText = "UPDATE Payments SET Paid = @p WHERE PlayerID ='" + PaymentForm.ID + "'";
    Cmd.Parameters.AddWithValue("@p", xxx);
    Cmd.ExecuteNonQuery();
}

I would like to know what goes in the place marked with three x's.

Palle Due
  • 4,918
  • 3
  • 19
  • 31

1 Answers1

3

Access uses -1 for TRUE and 0 for FALSE. So use 0 and -1.

Also, as pointet out by @ADyson you should parameterise all values in your SQL statements.

TheMixy
  • 727
  • 8
  • 27