StrataFrame Forum

edit a varchar(max) value give me a "String or binary data would be truncated" error

http://forum.strataframe.net/Topic16156.aspx

By Fabian R Silva, - - 5/5/2008

I have a "Valor" field (varchar(max)) on a "configuraciones" table, I can save the first time some data, but when I try to edit this same data (I find it with a seek and then edit the data and save it), I get an error "String or binary data would be truncated"

I try to alter this with a empty "" string and save it and it give me error anyway

I set debugon on the datasource and I see this:

[Deleted print out --- killed the page Smile]

I not sure if this are a bug, I save some new data (aprox 30000 bytes, with a base64 string from a memorystream of a devexpress grid savelayout method), edit this with some value and the "truncate" error happen :/

I will try with a text field and a fixed varchar value (something like 50000)

Additionally to this when I used the method "SetDebugOn" on my datasource with the 2nd parameter on true (overwritefile) If the file not exist it give me an error. (I not sure if the method have to create the file if it not exist)

Thanks for the great support.

-Fabian

By Trent L. Taylor - 5/5/2008

The problem is that you are using AllFields for your concurrency checking and have a MAX field.  If you want to allow this MAX field to be inclusive of the concurrency checking, then you need to use a row version field or time stamp field...which is far better anyway.  You can only take a VarChar(8000) as the max length on concurrency checking for All Fields.

Really if you want to use concurrency checking, you should be using Row Versioning anyway.  Create an integer field in the DB, and then specify this field name in the CRUD settings of the BO.

By Fabian R Silva, - - 5/6/2008

I have to say Sorry 2 times, 1 for the paste of the debug htm (I doesn't known that it can break the page Sad ) and another for my lack of knowledge about some topics, one of them that I forgive are concurrency stuff Blush



I put a int "RowVersion" field, on the BO set UpdateConcurrencyType to "rowversion" and set RowVersionOrTimestampColumn to "RowVersion" and all worked fine Smile many thanks.



- Fabian
By Trent L. Taylor - 5/6/2008

Fabian,

Please don't think I was upset in any way!!!  Absolutely no big deal at all.  As for the concurrency, I am glad that you found what you needed...you will be far better off using RowVersion checking versus AllFields anyway!

By Jéssica Neves - 10/21/2010

Hello would like to know how to read binary files from the database using my business object?

 I have already saved binary data, now wanted to know how do I recuperalos sql server?

Link has to help me?
By Ivan George Borges - 10/21/2010

Hi Jéssica.

What have you stored into your binary field? Are you using a Varbinary type? If so, have you customized your BO field to the type you need?
By Jéssica Neves - 10/21/2010

So, I am using VARBINARY(MAX) on SQL Server, and its mapped as a Byte[], I dont know if I have to mark the option Serialize Data or not. I'm not sure. In my database I need to store images, documents, many kinds of files. I just dont know how to recovery it. Do you have any sample like this?

Thanks in advance!
By Greg McGuffey - 10/21/2010

Take a look at this post and see if it helps: Business object mapper and images