ASCII character 0

  • I having some troubles with ASCII 0 on a SP.

    Recently one of the requirements of an old vb6 app is to add in a type 'text' column the content of a file.

    Now the program was parsing some characters such as " ' " replacing them for " '' ".

    But i don't know what to do when i get some null (ASCII 0) character. There is a special code for this character?<

    Thanks

  • Try this, could probably write it in a loop, bit brute force but should give you what you need:

    update

    TableName Set ColumnName = '' Where ascii(substring(ColumnName,1,1)) = 0

    update

    TableName Set ColumnName = left(ColumnName,1) Where ascii(substring(ColumnName,2,1)) = 0

    update

    TableName Set ColumnName = left(ColumnName,2) Where ascii(substring(ColumnName,3,1)) = 0

    update

    TableName Set ColumnName = left(ColumnName,3) Where ascii(substring(ColumnName,4,1)) = 0

    update

    TableName Set ColumnName = left(ColumnName,4) Where ascii(substring(ColumnName,5,1)) = 0

    update

    TableName Set ColumnName = left(ColumnName,5) Where ascii(substring(ColumnName,6,1)) = 0

    update

    TableName Set ColumnName = left(ColumnName,6) Where ascii(substring(ColumnName,7,1)) = 0

    update

    TableName Set ColumnName = left(ColumnName,7) Where ascii(substring(ColumnName,8,1)) = 0

    update

    TableName Set ColumnName = left(ColumnName,8) Where ascii(substring(ColumnName,9,1)) = 0

    update

    TableName Set ColumnName = left(ColumnName,9) Where ascii(substring(ColumnName,10,1)) = 0

    update

    TableName Set ColumnName = left(ColumnName,10) Where ascii(substring(ColumnName,11,1)) = 0

  • This is assumming that the null character is trailing, you will most likely need to rework this if the null catcter is anywhere in the string.

  • The app is doing an

    Exec StoreName 'FineName', FileSize, 'FileContents'

    the problem is that FileContents have an ASCII 0 and SQL throws an "Unclosed quotation mark before the character string 'ÿØÿà'". After "ÿØÿà" there is a ASCII character 0

    Any Suggestions??

  • REPLACE (<ColName>, CHAR(0), '')

    _____________
    Code for TallyGenerator

  • Remember that ASCII zero is C's (LPSTR) string terminator character. Sounds as if something is failing to read past it.

  • I've solved the issue from the VB side...

    I've started to use ADODb.Stream objects... and also I had to change the dolumnd type fom Text to Image (consecuently also I had to change several programs ).

     

     

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply