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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. COM
  4. Max Length of BSTR

Max Length of BSTR

Scheduled Pinned Locked Moved COM
databasesql-serversysadmintoolsquestion
5 Posts 5 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.
  • N Offline
    N Offline
    nativespirits
    wrote on last edited by
    #1

    I am building an Ad Hoc tool for work. Using a DLL to access the SQL Server database via ADO Smart Pointers (_RecordsetPtr, _ConnectionPtr). Anyway after I generate the SQL string the end user will create it gets truncated when converted to the BSTR datatype (which is necessary to pass out of the DLL via IDL). It appears to truncate at 511 chars (so I assume BSTR maxes at 512 with a NULL terminating character). What I need to know is if there is a way around this limitation. Is there a wrapper or function that expands the length of the BSTR to be passed? Or is there away to send it in pieces and have SQL Server concatenate it together when it receives it? I know that Query Analyzer, Cold Fusion and other tools pass incredibly long strings to SQL Server so it's got to be possible! Does anyone know the trick? Please let me know! Adam Murray Contract Programmer Microsoft Certified Professional

    D T M I 4 Replies Last reply
    0
    • N nativespirits

      I am building an Ad Hoc tool for work. Using a DLL to access the SQL Server database via ADO Smart Pointers (_RecordsetPtr, _ConnectionPtr). Anyway after I generate the SQL string the end user will create it gets truncated when converted to the BSTR datatype (which is necessary to pass out of the DLL via IDL). It appears to truncate at 511 chars (so I assume BSTR maxes at 512 with a NULL terminating character). What I need to know is if there is a way around this limitation. Is there a wrapper or function that expands the length of the BSTR to be passed? Or is there away to send it in pieces and have SQL Server concatenate it together when it receives it? I know that Query Analyzer, Cold Fusion and other tools pass incredibly long strings to SQL Server so it's got to be possible! Does anyone know the trick? Please let me know! Adam Murray Contract Programmer Microsoft Certified Professional

      D Offline
      D Offline
      Daniel Turini
      wrote on last edited by
      #2

      nativespirits wrote: I am building an Ad Hoc tool for work. Using a DLL to access the SQL Server database via ADO Smart Pointers (_RecordsetPtr, _ConnectionPtr). Anyway after I generate the SQL string the end user will create it gets truncated when converted to the BSTR datatype (which is necessary to pass out of the DLL via IDL). It appears to truncate at 511 chars (so I assume BSTR maxes at 512 with a NULL terminating character). I don't know how long they can be, but I guess they can be as long as available system memory. This should be enough for your query :) Are you using wsprintf for building the query? wsprintf has a limit of 1024 bytes, wich should be 512 chars on a UNICODE build. If so, use _snwprintf... Q261186 - Computer Randomly Plays Classical Music

      1 Reply Last reply
      0
      • N nativespirits

        I am building an Ad Hoc tool for work. Using a DLL to access the SQL Server database via ADO Smart Pointers (_RecordsetPtr, _ConnectionPtr). Anyway after I generate the SQL string the end user will create it gets truncated when converted to the BSTR datatype (which is necessary to pass out of the DLL via IDL). It appears to truncate at 511 chars (so I assume BSTR maxes at 512 with a NULL terminating character). What I need to know is if there is a way around this limitation. Is there a wrapper or function that expands the length of the BSTR to be passed? Or is there away to send it in pieces and have SQL Server concatenate it together when it receives it? I know that Query Analyzer, Cold Fusion and other tools pass incredibly long strings to SQL Server so it's got to be possible! Does anyone know the trick? Please let me know! Adam Murray Contract Programmer Microsoft Certified Professional

        T Offline
        T Offline
        Todd Smith
        wrote on last edited by
        #3

        It's probably a limitation of ADO. There's one way to get around that problem but I don't think you want to hear it :( Todd Smith

        1 Reply Last reply
        0
        • N nativespirits

          I am building an Ad Hoc tool for work. Using a DLL to access the SQL Server database via ADO Smart Pointers (_RecordsetPtr, _ConnectionPtr). Anyway after I generate the SQL string the end user will create it gets truncated when converted to the BSTR datatype (which is necessary to pass out of the DLL via IDL). It appears to truncate at 511 chars (so I assume BSTR maxes at 512 with a NULL terminating character). What I need to know is if there is a way around this limitation. Is there a wrapper or function that expands the length of the BSTR to be passed? Or is there away to send it in pieces and have SQL Server concatenate it together when it receives it? I know that Query Analyzer, Cold Fusion and other tools pass incredibly long strings to SQL Server so it's got to be possible! Does anyone know the trick? Please let me know! Adam Murray Contract Programmer Microsoft Certified Professional

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          BSTRs have no limitation other than physical memory and address space size (2GB). Something else is truncating your strings. --Mike-- "I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click! My really out-of-date homepage Sonork-100.19012 Acid_Helm

          1 Reply Last reply
          0
          • N nativespirits

            I am building an Ad Hoc tool for work. Using a DLL to access the SQL Server database via ADO Smart Pointers (_RecordsetPtr, _ConnectionPtr). Anyway after I generate the SQL string the end user will create it gets truncated when converted to the BSTR datatype (which is necessary to pass out of the DLL via IDL). It appears to truncate at 511 chars (so I assume BSTR maxes at 512 with a NULL terminating character). What I need to know is if there is a way around this limitation. Is there a wrapper or function that expands the length of the BSTR to be passed? Or is there away to send it in pieces and have SQL Server concatenate it together when it receives it? I know that Query Analyzer, Cold Fusion and other tools pass incredibly long strings to SQL Server so it's got to be possible! Does anyone know the trick? Please let me know! Adam Murray Contract Programmer Microsoft Certified Professional

            I Offline
            I Offline
            ian mariano
            wrote on last edited by
            #5

            If you need to get a long string out of an ADO recordset, use the GetChunk method, you can call it over and over until all your text is retrieved. Conversely, to place a long string into an ADO recordset you'd use AppendChunk. Append/GetChunk can be used for more than strings, they can be used on binary data columns as well. AppendChunk()[^] / GetChunk()[^] -- ian


            http://www.ian-space.com/

            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