Use in operator in stored query in ms access with ado.net

103 Views Asked by At

Following is my stored query in ms access

UPDATE tblContacts SET isActive = 0, DtUpdated = vDtUpdated
WHERE ContactId in (vContactId);

ContactId is integer.

Following is my c# code which executes the above stored query

    public void Delete(string contactId)
        {
            using (var cm = new OleDbCommand())
            {
                cm.Connection = AccessConnection();
                cm.CommandType = CommandType.StoredProcedure;
                cm.CommandText = "deltblContacts";
                cm.Parameters.AddWithValue("vDtUpdated", DateTime.Now.ToString());
                cm.Parameters.AddWithValue("vContactId", contactId);
                cm.Connection.Open();
                cm.ExecuteNonQuery();
                cm.Connection.Close();
      }
}

When i execute the above code, not a single record is affected.

I feel that passing data to the stored query in string form is the pain point.

0

There are 0 best solutions below