SQL field type needed for a serializable BO field


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I was going to try out this serializable thingy, i.e. try to store a bitmap (are other image types supported?) in a table field. What should the SQL column be defined as? varbinary? varchar?
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You will use a VarBinary(MAX) for SQL Server 2005 and Image for SQL Server 2000.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks!



Next question: how do you allow a user to upload an image into this sort of field, so it can be saved?
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The column will be created as a Byte[] field on the business object, so if you set the field to any byte array, then you can just save it and it will dump it to the database. 

However, if you're talking about letting your users upload things on your website... I'm not sure.  There are controls you can use to upload objects to your webserver, and there might be one in the basic ASP.NET controls, but I've never used one.

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Actually, I'm talking about WinForms. I think I might have figured it out. Something like:





' imageFile is the full path to an image

MyPictureBox.Image = CType(New Bitmap(imageFile), Image)





If MyPictureBox is bound via SF, then saving it should save the serialized bitmap back to db right?
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Ah...one more question (ok, maybe there will be more): How do I handle NULLs in the BO? I.e. the image may not be required, so how do I handle that. The Generic Nullable didn't work. What is an appropriate replacement value?
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
f MyPictureBox is bound via SF, then saving it should save the serialized bitmap back to db right?

Correct. 

The Generic Nullable didn't work. What is an appropriate replacement value?

Just return an alternate value and put something like this:

New CType(System.Drawing.Bitmap(1,1), System.Drawing.Image)

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search