CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2001
    Location
    Salzburg, Austria
    Posts
    126

    Does is exist a limit with string?

    Hi!
    I try to execute an SQL that has been builded on a string. When I show the value of the string, it seems like the string had just the first 255 positions of the whole SQL, and of course I become an error from the ODBC driver (in this case is an INSERT instruction). Is it possible to execute SQL longer than 255 characters?
    Thanks in advance.
    Jaime.


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Does is exist a limit with string?

    This shouldn't be any problem, so I think you need to look for the reason that your string is only 255 long.

    How is the string declared, strings can be declare being fixed length, possibly resulting in data loss.

    What actions do you do with the string? Sometimes people do actions like Left, mid, right and stuff on a string, in order to get only a part of the data, like for instance (often used when dealing with SQL) to chop off trailing comma's. Check if you don't chop off the wrong part, or that you made a miscalculation for the length.

    Finally, check if all variable names are correct, turn on option explicit to be sure, and double check if you are really adding the data to the correct string.
    I once saw this guy building a huge WHERE clause for his SQL string, but at the end, in stead of writing strSQL = strSelect & strWhere he wrote strSQL = strSQL & strSQL. These kind of error are very common, and can be a pain in the a**, cause you always look over them.



    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    May 2001
    Location
    Canada
    Posts
    182

    Re: Does is exist a limit with string?

    I met the same problem before. It seems that the maximum of string in VB has the limit of 255. If you can make a deep research on it, I'd like to hear the best solution. What I did before is shrinking the SQL string. :-(

    Regards,

    Michi
    MCSE, MCDBA

  4. #4
    Join Date
    Jan 2001
    Posts
    165

    Re: Does is exist a limit with string?

    I have to agree with Cakkie on this one.

    Quote from MSDN:

    The String data type can store fixed-length strings ranging in length from 0 to approximately 63K characters and dynamic strings ranging in length from 0 to approximately 2 billion characters.

    I have built a SQL query that was well over 255 characters with no problem. I did sometimes have problems when trying to check what was actually in the string. For example is a message box limited in display length? Maybe your string is being truncated by something else.

    But it is possible to store more than 255 characters in the string.

    -K


  5. #5
    Join Date
    Aug 2000
    Location
    KY
    Posts
    766

    Re: Does is exist a limit with string?

    I have seen this problem, it has to do with
    ADO limitation rather than VB string. I was passing in a large IN List that each item was wrapped with ' instead of " , i used the replace function before executing the call and it worked fine.



  6. #6
    Join Date
    Aug 2000
    Location
    KY
    Posts
    766

    Re: Does is exist a limit with string?

    I have seen this problem, it has to do with
    ADO limitation rather than VB string. I was passing in a large IN List that each item was wrapped with ' instead of " , i used the replace function before executing the call and it worked fine. You might want to try this, I hope it helps




  7. #7
    Join Date
    Jul 2001
    Location
    Salzburg, Austria
    Posts
    126

    Re: Does is exist a limit with string?

    Ok.
    I found about the stupid problem.
    You are right, I got it to work.
    Thaks.
    Jaime.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured