Query value of nvarchar(max) return empty with Qt 5



  • Hello everybody,

    I've executed a query on my SQL Server 2016 Database and using "ODBC Driver 13 for SQL Server" I've tried to read table's data. It works fine for all columns just on witch have nvarchar(max) datatype. The value read is empty but the column contains data.

    ```
    

    m_sCommandQuery = "SELECT CDF_TEXTE FROM [Theriaque].[cdc].[theriaque_CDF_CODIF_CT] theria_tab inner join [Theriaque].[cdc].[lsn_time_mapping] cdc on theria_tab.[__$start_lsn] = cdc.[start_lsn] where (convert(date, tran_end_time,103) > convert(date,'29/03/2017',103)) and (convert(date, tran_end_time,103) <= convert(date, '27/08/2017',103)) and $operation = 4 and CDF_NUMERO_PK ='07' and CDF_CODE_PK = '1661' order by theria_tab.$seqval ";

    
    

    queryUpdateCmd.value(0).toString(); return "";

       
    I've tried to read data using cast and it works fine !
    Also, I've tried to convert the read data to UTF or Latin1 but usully I've empty value.
    The problem I can't user cast beause I've reading data dynamicly.
    
    Can anyone tell me where I'm wrong and tell me what I must do to resolve this problem

  • Lifetime Qt Champion

    Hi,

    What if you convert to QByteArray rather than QString ?



  • Thanks for your reply.

    I've tried to use QByteArray like

    QByteArray ba = queryUpdateCmd.value(0).toByteArray();
    

    but ba is empty too. In fact, when I try to display queryUpdateCmd.value(0) as QVariant, I found that the is null. I think the problem is when selecting a nvarchar(max) but I don't know how to resolve it.



  • When I change my request to select cast(CDF_TEXTE as nvarchar(max)) from table, it returns the right value.


  • Lifetime Qt Champion

    Glad you found a solution and thanks for sharing !

    Did you try to take a look at the bug report system to see if there's something related ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.