Business Objects and VarBinary(Max) fields...


Author
Message
Robin J Giltner
Robin J Giltner
StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)
Group: Forum Members
Posts: 105, Visits: 650
It was decided that we would store files the user selects in the database for several reason.  I've implemented this in 2 databases, since we are using Sql Express on the clients db size was in mind.  One db has the record for the data about the file with an FK to the other database with the file data. 

The database with the file data has one table, with 2 fields, a PK and the varbinary(max) field. I haven't had any problems navigating between the business objects, editing and deleted.  The problem I'm having is with adding a new file.

The Code basically instances the FileData BO, creates a newrow (the PK Guid is generated by code in the BO), sets the varbinary(max) field to the byte array returned from the My.Computer.FileSystem.ReadAllBytes method. Then I call save on the BusinessObject.

This method runs great with small files < 1mb, but if it goes over say 10-15mb it hangs and errors out.  So I thought I would step through and see where it is dropping out.  But when I step through the code, it seems to run and complete and returns the Microfour.Strataframe.Business.SaveOjbect (forgot the whole namespace) Success.

So I ditched the BusinessObject thinking it was just having problems with varbinary(max) fields and just wrote the ADO code, but then I remember you guys talking about storing images in your Medical software in a similar fashion. 

So I figured I'd throw this to you guys and see if you have any pointers.

Thanks,

Robin Giltner

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
With large files, you're most likely dealing with a network bandwidth issue... not saying that your bandwidth is low, but that saving/retrieving the data to/from the server is going to block on the update/retrieval method.  So, while the byte array is being transfered across the network, the application will lock up.  It's probably the case that the SQL Server ADO.NET client is timing out and throwing a SqlException indicating that the method timed out.  If I were you, I would look into breaking up the file parts into 100K or 1MB pieces and adding one more field to your table that indicates the order of the parts within the file.  Then, you can save the parts one at a time and show a progress to the end user.  Then you can work with the size of the file parts until you get find a size that will allow you to avoid the timeout issues with SQL Server because I know many of your users are going to be using the system from remote.
Robin J Giltner
Robin J Giltner
StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)StrataFrame User (137 reputation)
Group: Forum Members
Posts: 105, Visits: 650
Ah, excellent suggestion as always.

Thanks Ben.

Have a good weekend.

Robin Giltner

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You too... and if you want to raise an event to show the progresss of your saving, then you can create a data source class that inherits from SqlDataSourceItem and overrides the UpdateRow() method.  All you would have to do is raise the event and then call MyBase.UpdateRow() or something like that... otherwise, you'll have to save each piece one at time or else the business object will block on the Save() method until all of the parts are saved... which keeps SQL from timing out, but kinda defeats your ability to show a progress update.  Your call.
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