Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MSSQL and stored procedure
Forum Updated to NodeBB v4.3 + New Features

MSSQL and stored procedure

Scheduled Pinned Locked Moved General and Desktop
raspberrymssql
1 Posts 1 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    savior
    wrote on 1 Oct 2015, 06:38 last edited by
    #1

    Hi,
    How do I read nvarchar (255) output value of the stored procedure:

    db = QSqlDatabase::addDatabase("QODBC3");
    db.setDatabaseName("Driver={SQL Server};Server=homepc\\SQLEXPRESS;Database=Test_DB;");
    db.setUserName("sa");
    db.setPassword("sa");
    if (!db.open())
    {
        qDebug() << "Error";
    }else{
        qDebug() << "OK";
    }
    
    QVariant strValue(QString(255,' ')); 
    int n = 0;
    
    QSqlQuery query;
    query.setForwardOnly(true);
    QString sqlString = "{CALL test(:Name,:Str,:Number)}";
    query.prepare(sqlString);
    query.bindValue(":Name","Test");
    query.bindValue(":Str", strValue, QSql::Out);
    query.bindValue(":Number", n, QSql::Out);
    if (!query.exec()) qDebug() << query.lastError().text();
    qDebug() << query.boundValue(":Number").toInt();
    qDebug() << query.boundValue(":Str").toString();
    

    lasterror return "QODBCResult::exec: Unable to execute statement: "[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid parameter 2 (''): Data type 0x63 is a deprecated large object, or LOB, but is marked as output parameter. Deprecated types are not supported as output parameters. Use current large object types instead."
    "[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid parameter 2 (''): Data type 0x63 is a deprecated large object, or LOB, but is marked as output parameter. Deprecated types are not supported as output parameters. Use current large object types instead. QODBC3: Unable to execute statement"

    If I set less value for a string size for example QVariant strValue(QString(100,' ')); stored procedure return value, itherwise value is empty.

    How to correctly read the value?
    Regards

    Qt 4.8.2 and raspberry pi [TDS][ODBC]

    1 Reply Last reply
    0

    1/1

    1 Oct 2015, 06:38

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved