I have a C# method that accepts a clientId (int) and hasPaid (boolean) that represents if the client has paid or not. The MS SQL Server stored procedure expects a BIT value (1 or 0) for the @HasPaid parameter yet the method expects a boolean type (true/false) for hasPaid. Will the ADO.NET code take care of converting the boolean to a bit type for SQL Server or do I need to convert the value of hasPaid into a 1 or 0?
public void UpdateClient(int clientId, bool hasPaid)
{
using (SqlConnection conn = new SqlConnection(this.myConnectionString))
{
using (SqlCommand sqlCommand = new SqlCommand("uspUpdatePaymentStatus", conn))
{
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.Parameters.AddWithValue("@ClientID", clientId);
sqlCommand.Parameters.AddWithValue("@HasPaid", hasPaid);
sqlCommand.Connection.Open();
var rowsAffected = sqlCommand.ExecuteNonQuery();
}
}
}
1 or 0