3

I have to store multiple files in a Database. In order to do that I am using jQuery Multiple File Uplaod control written by blueimp. For the server language I use asp.net. It uses a handler – ashx which accepts every particular file and stores it in the DB. In my DB I have a stored procedure which returns the document id of the currently uploaded file and then stores it into the DB. This is a code fragment from it which shows that getting this id is a 3 step procedure:

SELECT TOP 1 @docIdOut = tblFile.docId -- ,@creator=creator,@created=created FROM [tblFile] WHERE friendlyname LIKE @friendlyname AND @categoryId = categoryId AND @objectId = objectId AND @objectTypeId = objectTypeId ORDER BY tblFile.version DESC

  IF @docIdOut = 0        BEGIN --get the next docId          SELECT TOP 1

@docIdOut = docId + 1 FROM [tblFile] ORDER BY docId DESC END

  IF @docIdOut = 0        BEGIN --set to 1            SET @docIdOut = 1       END

If more than one calls to that stored procedure are executed then will be a problem due to inconsistency of the data, but If I add a transaction then the upload for some files will be cancelled.

https://dl.dropboxusercontent.com/u/13878369/2013-05-20_1731.png

Is there a way to call the stored procedure again with the same parameters when the execution is blocked by transaction?

Another option is to use the blueimp plugin synchronously with the option “sequentialUploads = true” This option works for all browsers except firefox, and I read that it doesn’t work for Safari as well.

Any suggestions would be helpful. I tried and enabling the option for selecting only one file at a time, which is not the best, but will stop the DB problems (strored procedure) and will save the files correctly.

Thanks, Best Regards, Lyuubomir

4

1 に答える 1