Results 1 to 3 of 3

Thread: QSqlError("", "Parameter count mismatch", "")

  1. #1
    Join Date
    Oct 2015
    Location
    Barcelona, Spain
    Posts
    7
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows Android

    Default QSqlError("", "Parameter count mismatch", "")

    Hello,
    Sorry for my English. I'm trying to select some data from a database table in order to insert the into a table from another database.

    I've saved every value of each database in QStrings like these:

    Qt Code:
    1. QString _Telefono = seleccionar2.value(8).toByteArray().constData();
    2. QString _Tecnico_Asignado = seleccionar2.value(0).toByteArray().constData();
    3. QString _Estado_Solicitud = seleccionar2.value(7).toByteArray().constData();
    To copy to clipboard, switch view to plain text mode 

    And when I use this code:

    Qt Code:
    1. QSqlQuery guardar_s;
    2. guardar_s.prepare("INSERT INTO Solicitudes_Trabajo (N_Solicitud, Fecha_Emision, Unidad_Hospitalaria,"
    3. "Codigo_Equipo, Equipo, Marca)"
    4. "VALUES (:N_Solicitud, :Fecha_Emision, :Unidad_Hospitalaria, :Codigo_Equipo, :Equipo,"
    5. ":Marca)");
    6. guardar_s.bindValue(":N_Solicitud", _N_Solicitud);
    7. guardar_s.bindValue(":Fecha_Emision", _Fecha_Emision);
    8. guardar_s.bindValue(":Unidad_Hospitalaria", _Unidad_Hospitalaria);
    9. guardar_s.bindValue(":Codigo_Equipo", _Codigo_Equipo);
    10. guardar_s.bindValue(":Equipo", _Equipo);
    11. guardar_s.bindValue(":Marca", _Marca);
    To copy to clipboard, switch view to plain text mode 

    It works fine, and inserts the values into the table perfectly, but when I use this other code;

    Qt Code:
    1. QSqlQuery guardar_s;
    2. guardar_s.prepare("INSERT INTO Solicitudes_Trabajo (N_Solicitud, Fecha_Emision, Unidad_Hospitalaria, Codigo_Equipo,"
    3. "Equipo, Marca, Modelo, N_Serie, Localizacion, Unidad_Tecnica, Peticionario, Telefono, "
    4. "Descripcion_Solicitud, Tecnico_Asignado, Tipo_Solicitud, Estado_Solicitud) "
    5. "VALUES (:N_Solicitud, :Fecha_Emision, :Unidad_Hospitalaria, :Codigo_Equipo, :Equipo, :Marca, :Modelo,"
    6. ":N_Serie, :Localizacion, :Unidad_Tecnica, :Peticionario, :Telefono, :Descripcion_Solicitud,"
    7. ":Tecnico_Asignado, :Tipo_Solicitud, :Estado_Solicitud)");
    8. guardar_s.bindValue(":N_Solicitud", _N_Solicitud);
    9. guardar_s.bindValue(":Fecha_Emision", _Fecha_Emision);
    10. guardar_s.bindValue(":Unidad_Hospitalaria",_Unidad_Hospitalaria);
    11. guardar_s.bindValue(":Codigo_Equipo", _Codigo_Equipo);
    12. guardar_s.bindValue(":Equipo", _Equipo);
    13. guardar_s.bindValue(":Marca", _Marca);
    14. guardar_s.bindValue(":Modelo", _Modelo);
    15. guardar_s.bindValue(":N_Serie", _N_Serie);
    16. guardar_s.bindValue(":Localizacion", _Localizacion);
    17. guardar_s.bindValue(":Unidad_Tecnica", _Unidad_Tecnica);
    18. guardar_s.bindValue(":Peticionario", _Peticionario);
    19. guardar_s.bindValue(":Telefono", _Telefono);
    20. guardar_s.bindValue(":Descripcion_Solicitud", _Descripcion_Solicitud);
    21. guardar_s.bindValue(":Tecnico_Asignado", _Tecnico_Asignado);
    22. guardar_s.bindValue(":Tipo_Solicitud", "a");
    23. guardar_s.bindValue(":Estado_Solicitud", _Estado_Solicitud);
    To copy to clipboard, switch view to plain text mode 

    It doesn't work and shows the error:
    Qt Code:
    1. .ERROR: QSqlError("", "Parameter count mismatch", "").
    To copy to clipboard, switch view to plain text mode 

    Are these too much data to insert for Qt Creator? Why it is able to insert 6 values but it isn't able to insert 16 values?

    Thanks for replying!

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QSqlError("", "Parameter count mismatch", "")

    Qt Creator isn't relevant to what you are trying to do, but if you're asking if the Qt Database related classes can handle more than 6 bound parameters, the answer is yes. Does your table definition have a column that is NOT NULL perhaps that is missing from your insert statement?
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlError("", "Parameter count mismatch", "")

    Is the call to prepare() returning true?

Similar Threads

  1. Replies: 14
    Last Post: 16th May 2017, 03:51
  2. Replies: 3
    Last Post: 16th March 2015, 07:31
  3. Replies: 3
    Last Post: 15th December 2014, 16:24
  4. Replies: 3
    Last Post: 25th August 2009, 13:03
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.