Jack Ferdinand
Jack Ferdinand

Reputation: 13

what do i write into c# to edit the data in an access database

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.

Upvotes: 1

Views: 98

Answers (1)

TheMixy
TheMixy

Reputation: 1296

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.

Upvotes: 3

Related Questions