0

Possible Duplicate:
Local DB throws Byte array truncation to a length of 8000 exception

The SQL database on the phone won't let me store a byte array bigger than 8000 bytes. I've looked at other datatypes here:

http://msdn.microsoft.com/en-us/library/ms172424(SQL.110).aspx

but types that hold more data, like NTEXT, can't be used in WP7. I need to store a byte array of length greater than 300,000 bytes.

Any ideas how I can get around this issue?

Any help is appreciated!

Edit: The whole idea is to store an image as a byte array on a local and on a remote server.

Community
  • 1
  • 1
Cameron
  • 430
  • 2
  • 11
  • This isn't meant to be smart-alecky, but perhaps you should re-factor the design. There are limits for reasons. Phones aren't yet full-fledged PCs, and lack the power and memory of a true PC. – David Dec 08 '11 at 21:56
  • I understand, however I need to transmit this data to a server which will then store it in an SQL database. The whole idea is to store an image as a byte array on a local and on a remote server. – Cameron Dec 08 '11 at 23:23
  • It's a duplicate, since the answer is precisely the same. So it should be closed. – Claus Jørgensen Dec 09 '11 at 07:24
  • Agreed - do I close it, or do I need a mod to do that? – Cameron Dec 09 '11 at 13:47
  • @Cameron: just let it be. The community will eventually close it now that it's been flagged. – ctacke Dec 09 '11 at 15:01

1 Answers1

1

I think the Image datatype is supported.
See here http://msdn.microsoft.com/en-us/library/hh286406(v=VS.92).aspx#BKMK_WorkingWithBLOBData

I would strongly consider storing data this large in Isolated Storage though, with a guid file name, then store the guid in the database.

Chris Sainty
  • 9,086
  • 1
  • 26
  • 31
  • It must be stored in a database as it must persist. Could you give me some more information about guid please? Seaching for it returns nothing useful. – Cameron Dec 08 '11 at 22:09
  • @CameronFisher IsolatedStorage persists in the same way that a database does. A database is stored in isolated storage ;) – William Melani Dec 08 '11 at 22:29
  • Oh, well ok then. Anything I've previously written in isolated storage has been wiped when i restarted the phone/exit the app. Eventually this needs to be stored on a remote database so I still require a solution please :)... – Cameron Dec 08 '11 at 23:21
  • 1
    Closing the emulator and (I believe, not 100% sure) doing a full rebuild and deploy of your app will wipe out the isolated storage. As long as you leave the emulator running and just do incremental builds, anything in isolated storage should be persisted. – Garrett Kiel Dec 09 '11 at 00:03
  • I must be doing something wrong then because it doesn't persist even on my WP. I have however sorted this problem, you think you've searched everywhere and then suddenly! I can't post the answer until tomorrow though (as I'm a new user). – Cameron Dec 09 '11 at 00:14
  • If the `varbinary(MAX)` type is supported in SqlCE, it should be used in preference to `image`. – Richard Szalay Dec 09 '11 at 09:52
  • 1
    @richard: varbinary(max) is not supported. For longer data (i.e. > 8000 bytes) you must use an image type. – ctacke Dec 09 '11 at 15:01