Categories
Dynamics NAV Microsoft SQL Server

Microsoft Dynamics NAV – “The following ODBC error occurred: Error: [Microsoft][ODBC Driver Manager] Invalid string or buffer length State ID: HY090”

—————————
Microsoft Dynamics NAV Development Environment
—————————
The following ODBC error occurred:

Error: [Microsoft][ODBC Driver Manager] Invalid string or buffer length
State ID: HY090
—————————
OK
—————————

When you try to read a Microsoft Dynamics NAV (formerly Microsoft Business Solutions Navision) BLOB Data Type field with an ODBC connection or simply to do a Backup of Navision show the following this error message:

Invalid string or buffer length

Cause:

When you use Microsoft Dynamics NAV BLOB field with Compressed Property to No and SubType Property to Memo is possible to write values from 4 bytes to 2 GB.

Solution:
Write something (like 4 spaces) in the field to cover the 4 byte in all the rows with blob field containing less then 4 bytes.

You can run a query in SQL Server like this:

SELECT *
FROM [TableName]
where DATALENGTH([ImageColumn]) < 4

Did my solution solve your problem? Leave a reply.