Insert QODBC from C #

312 Views Asked by At

I am trying to insert data into the "Transaction" table of Quickbooks through QODBC but I receive the following error:

System.Data.Odbc.OdbcException: 'ERROR [42S00] [QODBC] Data type mismatch for one or more field. Invalid operand for operator: <assignment>'

I get this same error using VBDEMO, I have tried several ways but I get the same error.

I attach the code that I use in C #:

string entity = "MARIA";
string Account = "DISPONIBLE:EFECTIVO Y EQUIVALENTES AL EFEC:1112  BANCOS,2020-03-12";
string amount ="400";
string Memo = "Pruebas Migracion";
DateTime date = Convert.ToDateTime("2020/03/12");


OdbcCommand comm = conn.CreateCommand();
//comm.CommandText = "INSERT INTO Transaction(EntityRefFullName,AccountRefFullName,TxnDate,Amount,Memo) VALUES('"+ entity + "','" + Account + "','" + fecha + "','" + amount + "','" + Memo +  "')";
comm.CommandText = "INSERT INTO Transaction(TxnDate,Amount) VALUES('" + date.ToShortDateString() + "'," + amount + ")";
MessageBox.Show(comm.ExecuteNonQuery().ToString());
0

There are 0 best solutions below