For @Christian Schmitz , and hopefully a solution for all to see.
I store my text in VARCHAR() fields with the INSERT Prepared Statement commands within SQLDatabaseMBS and this works OK. It stores up to 4000 characters.
I now need to store an email plain text message with a corresponding HTML equivalent. I am using the API 2.0 compatible SQLPreparedStatementMBS.ExecuteSQLMT statement to do the INSERT. I am having two issues:
- Even though the plain text field is VARCHAR(3999) and the plain text is about 3,500 characters, it gives the error HY104 [Microsoft][ODBC Driver 17 for SQL Server]Invalid precision value.
- I have defined the HTML field as NVARCHAR(Max) and the HTML text is about 5,000 characters. If I use BindType SQLPreparedStatementMBS.kTypeString I get an error that it cannot convert. If I use BindType SQLPreparedStatementMBS.kTypeLongChar it gives the error below. BTW there is no ‘image’ or weird non-ASCII characters in the HTML.
42000 [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared.
22018 [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Operand type clash: image is incompatible with nvarchar(max)
I can add the HTML text if I define the database field as VBINARY(MAX) and use BindType SQLPreparedStatementMBS.kTypeLongBinary, but it stores and retrieves as Base64. I have tried defining the database field as TEXT, but get the same Invalid precision value error.
Online searches suggest this may be an ODBC issue ie the CURL driver within SQLDatabaseMBS, but these ‘solutions’ were from years ago, so there must be a solution today.
How are you supposed to store medium-large text fields in MSSQL using SQLDatabaseMBS? Is SQLDatabaseMBS accidentally Binding SQLPreparedStatementMBS.kTypeLongChar as an ‘image’?