Operand types are not compatible with the operator at insertion AX to MYSQL database with numerical values.

I am facing an error (Operand types are not compatible with the operator) at the time of insertion from AX 2012 R3 to MySQL Database using variable.

someone guide me how to insert numerical values using variables from AX 2012 r3 to MySQL database through AX job.

int age = 30;

real hourly_rate = 15.25;

cmdSelect.set_CommandText(“INSERT INTO my_table (emp_id, emp_name, emp_age, hourly_rate) VALUES (‘1’,‘ABC’, ‘C-Class’, '”+age+"’,’"+hourly_rate+"’);");

Operand types are not compatible with the operator;

thanks in advance.

I see that you’re putting quotation marks around those numeric values. I think that’s the problem.

By the way, the usual approach is using strFmt() instead of using + operator. Like this:

strFmt("INSERT INTO my_table (emp_id, emp_name, emp_age, hourly_rate) VALUES ('1','ABC', 'C-Class', %1, %2)", age, hourly_rate);

let me try this.

thanks Martin its work for me.