By using parameters you will be able to insert the special characters. For example:
private void InsertMethod(string code, string input)
{
using (var conn = new SqlConnection(ConnectionString))
{
con.Open();
var myQuery = "insert into [log] ([code],[input]) values (@code, @input)";
var paramCode = new SqlParameter("@code", SqlDbType.NVarChar) {Value = code};
var paramInput = new SqlParameter("@input", SqlDbType.NVarChar) {Value = input};
using (var cmd = new SqlCommand(myQuery conn))
{
cmd.Parameters.Add(paramCode);
cmd.Parameters.Add(paramInput);
cmd.ExecuteNonQuery()
}
}
}
In this example I use the SqlDbType.NVarChar. You can use a whole series of types that of course should match you table structure.