Error log

INSERT INTO Delivery_statistics (Номенклатура товара, Кол-во, Цена,Дата) VALUES('Карандаш', 111, 15,#01/01/2017#)" QODBCResult::exec: Unable to execute statement: "[Microsoft][Диспетчер драйверов ODBC] Ошибка последовательности функций" "[Microsoft][Диспетчер драйверов ODBC] Ошибка последовательности функций" "QODBC3: Unable to execute statement"` 

Code

  QSqlQuery Query; QString QueryStr = "INSERT INTO "+nameTable+" (Номенклатура товара, Кол-во, Цена,Дата) VALUES('Карандаш', 111, 15,#01/01/2017#)"; qDebug()<<QueryStr; Query.prepare(QueryStr); if(!Query.exec()) { qDebug()<<Query.lastError().databaseText(); qDebug()<<Query.lastError().driverText(); } 

    2 answers 2

    If it is Access, try this:

     QString QueryStr = "INSERT INTO "+nameTable+" ([Номенклатура товара], [Кол-во], Цена,Дата) VALUES('Карандаш', 111, 15,#01/01/2017#)"; 
    • Thanks buddy! You can explain on the fingers what the framing of the [Product nomenclature] and [Qty] parameters with the nomenclature is due to square brackets, probably because of this that it is (array = string), but why does the number parameter need brackets? - hays
    • 2
      Required if the name contains invalid characters, for example: space, hyphen. - msi
    • And how to fix it? "[Microsoft] [ODBC Driver Manager] Function Sequence Error" "QODBC3: Unable to execute statement" "INSERT INTO Delivery_statistics ([Product Line], [Qty.], Price, Date, [Client]) VALUES ('Pen' , 100,100, # 05/01/2017 #, 'LLP StroyTorgVse' " - hays
    • Probably the problem is in the parameter of StroyTorgVse LLP ... Is it necessary to screen it somehow ?! - hays
    • If this is the entire query, then there is no closing bracket. - msi

    Last parameter must be in quotes

    • Welcome to Stack Overflow in Russian! Please try to leave a little more detailed answers. You can add an answer by clicking edit - aleksandr barakin