locked
How insert a files directory path into Access database? RRS feed

  • Question

  • I am creating a website and one of the feature is that you can upload a txt file into the project directory /quizses folder.

    How do I get "/quizzes/stuff.txt"

    Stored into my access database?

    • Moved by Eason_H Wednesday, November 20, 2013 7:44 AM
    Tuesday, November 19, 2013 11:54 PM

Answers

  • you don't actually have a path from asp.net. You need to first save the posted data if you want a path. Search "FileUpload.SaveAs" on www.asp.net for samples code.

    For more help in programming web sites using asp.net, visit forums.asp.net.



    Visual C++ MVP

    • Proposed as answer by Just Karl Wednesday, November 20, 2013 6:33 PM
    • Marked as answer by Just Karl Monday, December 2, 2013 4:28 AM
    Wednesday, November 20, 2013 12:22 AM
  • Generall Website stuff is better asked in teh ASP.Net Forum

    A Simple String/Varchar of sufficient lenght. 50 should normally be enough, but afaik maximum path lenght was somewhere closer to 256 to 65536. So better pick that high a value to be save.

    However this is only one of three appraoches to store a BLOB (Binary Large Object) with a Database.

    You use the appraoch of storing the file in the filesystem, storing path in DB. This can cause problems with identical filenames, transactional integrity and when making a Backup.

    Another appraoch is to store the files contents in a large varbinary column (wich has a limit of 2 GiB). Downside is that the performance for retreiving file is not optimal.

    The third approach is using Filestream. It slightly modifies how the second appraoch works so that storage and retrieval is done via Filesystem. More setup work but imho it is the beast way. You can use HTTP Handler to allow retrieval of file directly from the Database, as if it were a normal file on the disk.


    Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2 Please mark post as helpfull and answers respectively.

    • Proposed as answer by Just Karl Wednesday, November 20, 2013 6:33 PM
    • Marked as answer by Just Karl Monday, December 2, 2013 4:28 AM
    Wednesday, November 20, 2013 12:28 AM

All replies

  • you don't actually have a path from asp.net. You need to first save the posted data if you want a path. Search "FileUpload.SaveAs" on www.asp.net for samples code.

    For more help in programming web sites using asp.net, visit forums.asp.net.



    Visual C++ MVP

    • Proposed as answer by Just Karl Wednesday, November 20, 2013 6:33 PM
    • Marked as answer by Just Karl Monday, December 2, 2013 4:28 AM
    Wednesday, November 20, 2013 12:22 AM
  • Generall Website stuff is better asked in teh ASP.Net Forum

    A Simple String/Varchar of sufficient lenght. 50 should normally be enough, but afaik maximum path lenght was somewhere closer to 256 to 65536. So better pick that high a value to be save.

    However this is only one of three appraoches to store a BLOB (Binary Large Object) with a Database.

    You use the appraoch of storing the file in the filesystem, storing path in DB. This can cause problems with identical filenames, transactional integrity and when making a Backup.

    Another appraoch is to store the files contents in a large varbinary column (wich has a limit of 2 GiB). Downside is that the performance for retreiving file is not optimal.

    The third approach is using Filestream. It slightly modifies how the second appraoch works so that storage and retrieval is done via Filesystem. More setup work but imho it is the beast way. You can use HTTP Handler to allow retrieval of file directly from the Database, as if it were a normal file on the disk.


    Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2 Please mark post as helpfull and answers respectively.

    • Proposed as answer by Just Karl Wednesday, November 20, 2013 6:33 PM
    • Marked as answer by Just Karl Monday, December 2, 2013 4:28 AM
    Wednesday, November 20, 2013 12:28 AM
  • Overlooked that this is for Acces. So I guess Filestream will not work and I have to look what datatypes are avalible. Here is a list:

    http://msdn.microsoft.com/en-us/library/ms714540.aspx

    You still had VARBINARY avalible if you decided to store the bytes in the Database instead of the filesystem. You should consider it. As well as switching to a real SQL Database. Access is highly limited and even the free SQL-Server is much more powerfull.

    Paths must be stored as a String or a group of Chars, just like any other text. The 3 types concerning texts in access (ordered by avalible size) are:

    TEXT, LONG TEXT and MEMO.


    Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2 Please mark post as helpfull and answers respectively.

    Wednesday, November 20, 2013 1:51 AM
  • Hi trama09,

    Since the issue regards ASP.NET and website deployment. I suggestion you post the question in the ASP.NET forums at http://forums.asp.net/. It is appropriate and more experts will assist you.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, November 20, 2013 7:44 AM