Last post Jul 24, 2017 03:39 PM by PatriceSc
Jul 24, 2017 09:38 AM|hkbeer|LINK
My apps has a Fileupload control to upload doc. I am thinking to assign a unique consecutive ID as file name to it for identification instead of user upload file name as users may use same file name in some case. What is a working approach to assign this
ID and file name?
My plan is to get max ID from db storing DocIDs and add 1 to it on aspx on label and save name as this ID when user click "upload".
However what if user1 loads the page first but upload the file later than user2 who loads the same upload page later?
Jul 24, 2017 01:35 PM|PatriceSc|LINK
DocIDs doesn't have an identity value (maybe autoincrement depending on your db) ?. Getting a max value and adding 1 should be never needed are most if not all databases are able to do that for you.
Another approach could be to use a guid especially if you need to identify this file prior to adding a new entry for it inside your db.
Jul 24, 2017 03:25 PM|hkbeer|LINK
Jul 24, 2017 03:39 PM|PatriceSc|LINK
If I can I would reorder the operation ie I would add the row to get the id and would name my file this way.
If, not possible I would use
https://msdn.microsoft.com/en-us/library/system.guid.newguid(v=vs.110).aspx to generate a unique name and I would save this name to a column when I later add the file entry to the db.