How do I do an update query using the like operator with ‘%’ with sqlcommand?

I'm using SQL Server Compact Edition, which is why I am using

System.Data.SqlServerCe.SqlCeCommand cmdUp = new System.Data.SqlServerCe.SqlCeCommand(); 

I'm trying to use the following code, but I keep getting the error "Input string was not in a correct format" for @_fieldTwo

System.Data.SqlServerCe.SqlCeCommand cmdUp = new System.Data.SqlServerCe.SqlCeCommand(); cmdUp.CommandType = System.Data.CommandType.Text; cmdUp.CommandText = "UPDATE thisTable SET [thisField] = @_fieldOne WHERE [tableOne] LIKE @_fieldTwo + '%'"; cmdUp.Parameters.AddWithValue("@_fieldOne", _fieldOne); cmdUp.Parameters.AddWithValue("@_fieldTwo", _fieldTwo); cmdUp.Connection = conn; cmdUp.ExecuteNonQuery(); 

Thanks.

by privatly via /r/csharp

Leave a Reply