Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how get rid of the null character in a BSTR string?

how get rid of the null character in a BSTR string?

Scheduled Pinned Locked Moved C / C++ / MFC
questionlearning
5 Posts 2 Posters 0 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.
  • C Offline
    C Offline
    chenzhu
    wrote on last edited by
    #1

    Hi All, I have a BSTR string variable via ADO Recordset Getstring method. In the BSTR string has null character('\0'). How can I get rid them of in a common way(Of course I can loop from start of BSTR, but I want a directly way). Thank you. ;P chenzhu

    M 1 Reply Last reply
    0
    • C chenzhu

      Hi All, I have a BSTR string variable via ADO Recordset Getstring method. In the BSTR string has null character('\0'). How can I get rid them of in a common way(Of course I can loop from start of BSTR, but I want a directly way). Thank you. ;P chenzhu

      M Offline
      M Offline
      Masaaki Onishi
      wrote on last edited by
      #2

      Hello, the codegurus around the world.;) In fact, I don't understand your question a little bit. Do you want to take off "NULL" word from Column (display)? Or do you want to take off '\0' from all strings in Column? Or I miss something?:confused: Have a nice day! -Masaaki Onishi-

      C 1 Reply Last reply
      0
      • M Masaaki Onishi

        Hello, the codegurus around the world.;) In fact, I don't understand your question a little bit. Do you want to take off "NULL" word from Column (display)? Or do you want to take off '\0' from all strings in Column? Or I miss something?:confused: Have a nice day! -Masaaki Onishi-

        C Offline
        C Offline
        chenzhu
        wrote on last edited by
        #3

        Dear Masaaki Onishi, The last effect is my desire. I get a BSTR string has '\t' separator between columns and '\n' between rows. But int the string has excaptional '\0' just before a '\t'. I can not transform it to CString by W2A or WideCharToMultiByte functions directly because these annoying '\0'. Thanks. ;P chenzhu

        M 1 Reply Last reply
        0
        • C chenzhu

          Dear Masaaki Onishi, The last effect is my desire. I get a BSTR string has '\t' separator between columns and '\n' between rows. But int the string has excaptional '\0' just before a '\t'. I can not transform it to CString by W2A or WideCharToMultiByte functions directly because these annoying '\0'. Thanks. ;P chenzhu

          M Offline
          M Offline
          Masaaki Onishi
          wrote on last edited by
          #4

          Hello, the codegurus around the world.;) Do you try to use ADO in MFC or COM(ActiveX)?:confused: If you use ADO in MFC, we can use DataGrid control and this member function to display the data. As a result, we don't need to care about each data string. I often use Datagrid for ADO in MFC. Actually, MSDN has a good example called AdoDataGrid(?). However, if you want to use CListView or something to display your data, you may need to work your problem.:confused: Anyway, I want to sleep now. So, someone migh help you, or if I have a time.... Have a nice day! -Masaaki Onishi-

          C 1 Reply Last reply
          0
          • M Masaaki Onishi

            Hello, the codegurus around the world.;) Do you try to use ADO in MFC or COM(ActiveX)?:confused: If you use ADO in MFC, we can use DataGrid control and this member function to display the data. As a result, we don't need to care about each data string. I often use Datagrid for ADO in MFC. Actually, MSDN has a good example called AdoDataGrid(?). However, if you want to use CListView or something to display your data, you may need to work your problem.:confused: Anyway, I want to sleep now. So, someone migh help you, or if I have a time.... Have a nice day! -Masaaki Onishi-

            C Offline
            C Offline
            chenzhu
            wrote on last edited by
            #5

            Dear Masaaki Onishi, Thank you very much. Yes, I want a control to display the data. Actualy I am making a ATL control and the ATL control hold one Grid that accept format string in that pattern. The common usage is a VB project, which is the client of ATL COM control, opens one database and get one recordset, and then pass it into ATL control. Of course I can loop through whole recordset, read variant from every fields and assemble a CString by myself, but that is too tiresome. If you have waked up now has have a good mood, give me a advice. thank you. chenzhu :-O

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups