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. Query value of nvarchar(max) return empty with Qt 5
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.3k Views
  • 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.
  • M Offline
    M Offline
    mourad_bilog
    wrote on 28 Aug 2017, 15:27 last edited by
    #1

    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
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 28 Aug 2017, 20:11 last edited by
      #2

      Hi,

      What if you convert to QByteArray rather than QString ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mourad_bilog
        wrote on 29 Aug 2017, 07:55 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mourad_bilog
          wrote on 29 Aug 2017, 09:43 last edited by mourad_bilog
          #4

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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 30 Aug 2017, 21:02 last edited by
            #5

            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 ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            1/5

            28 Aug 2017, 15:27

            • Login

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