-1

I am trying to insert a row with a DATETIME field using MySqlX.XDevAPI. Whatever I try, I just get this cryptic message:

Expected token type IDENT at token pos 0

I have tried string format:

dt.ToString("yyyy-MM-dd HH:mm:ss")

I have tried UTC seconds format:

((DateTimeOffset)dt).ToUnixTimeSeconds();

I have also tried just passing System.DateTime instance as a value...Nothing works, and I can't find any documentation on how to do this simple task.

What is the correct format?

stuartd
  • 70,509
  • 14
  • 132
  • 163
Chebz
  • 1,375
  • 3
  • 14
  • 27
  • 1
    You need to give us a bigger hint as to what your code actually looks like. Anything at this point would pretty much be a guessing game. [mcve] – Barns May 26 '20 at 01:40
  • _I am trying to insert a row with a DATETIME field using MySqlX.XDevAPI._ - It looks to me that you're somehow generating invalid MySQL SQL. Do you have an example insert statement that raises this error? – stuartd May 26 '20 at 01:56
  • no MySqlX.XDevAP is a black box. The code is literally this: return DB.Instance.Schema.GetTable(_tableName).Insert(_data.Keys.ToArray()) .Values(_data.Values.ToArray()); – Chebz May 26 '20 at 02:46
  • if I could examine what string statement looks like I wont be asking this question. But there's no way afaik with this framework. – Chebz May 26 '20 at 02:47
  • everything works fine if I remove this field. – Chebz May 26 '20 at 02:47
  • the question is simple. How to set DateTime field using this framework in C#. My code is irrelevant. – Chebz May 26 '20 at 02:50

1 Answers1

1

Figured it out. Apparently it didn't like that the column was called "time" since it's a reserved keyword. Now this works: dt.ToString("yyyy-MM-dd HH:mm:ss")

Chebz
  • 1,375
  • 3
  • 14
  • 27