0

I have problem. I added new column into my db table. It is varchar(255) and it is nullable. When I added that column in my SQL query it throws error.

'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Function FROM Personnel' at line 1'

When I delete Function from query then it works fine. There isn't error in syntax.

   public static IEnumerable<Personnel> GetPersonnel()
    {
        using (var connection = DatabaseManager.CreateConnection())
        {
            return connection.Query<Personnel>(@"SELECT Id, Name, Phone1, Phone2, Address, CIN, Salary, RoleId, Function FROM Personnel");
        }
    }
  1. Personnel model have ' public string Function { get; set; } '
  2. Db table have

How to fix this? String can store null, where is problem?

SPIRINN
  • 61
  • 6
  • 1
    Function is a reserved word in MySQL. You might want to wrap the Function word in backticks. – Chetan Sep 09 '22 at 18:18

0 Answers0