#1
  1. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    UK
    Posts
    17
    Rep Power
    0

    Question Files to be stored in DB, how?? (MS SQL)


    Hi there,
    I am working on an application with which I want to upload files (word docs, PDFs etc.) to a MS SQL database from a website form (Browse button etc.).

    Unfortunately, I have no clue where to start. Could anyone point me into the right direction please?

    What type is the column where the file is stored in and how is the INSERT statement or UPDATE statement in SQL?

    Thanks for your help,
    N
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    249
    Rep Power
    14
    Hi,

    The type of the column should be "IMAGE" as this simply holds a series of bytes.

    You can use INSERT INTO mytable (Col1, MyDocColumn) VALUES (Something, :MyDoc)

    Prepare it and bind the parameter.

    As for your "browse" button and how to bind parameters, that all depends on your serverside programming language.
    Martijn Tonies
    Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle
    Upscene Productions
    http://www.upscene.com
  4. #3
  5. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    UK
    Posts
    17
    Rep Power
    0
    Thanks for the first pointers


    When you said INSERT... (...., :MyDoc), do you actually mean ":example.pdf"?

    I tried to find information about this in the official MS SQL Server Books, but with no success...

    The "bind" thing you mentioned, has this to be done on DB level?
    I am just provided the DB, ie. I have no DBA rights at all.
    I can access the tables, ie. INSERT, UPDATE, DELETE. This is as much as I can do...

    Thanks for your help.

    N
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    249
    Rep Power
    14
    Hi,

    When you said INSERT... (...., :MyDoc), do you actually mean ":example.pdf"?
    No, what I meant with :MyDoc, is that ":MyDoc" is a parameter.

    I come from a Delphi background, we use parameters often in queries. After preparing the query, we can then bind the parameter to the actual data.

    In Delphi, this would become:

    qry.ParamByName('MyDoc').LoadFromStream(the memory stream that has the document, inside the web-application that receives the web-form)

    (pseudocode of course).

    What language are you using server side?
    Martijn Tonies
    Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle
    Upscene Productions
    http://www.upscene.com
  8. #5
  9. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    UK
    Posts
    17
    Rep Power
    0

    PHP server side language


    Hi there,
    thanks for your reply.
    I am using PHP. For my websites, I normally use MySQL and I know my way round there, but MSSQL is slightly different.

    I have no probs inserting and updating data into MS SQL rows.

    So this parameter (makes more sense now), where would I set it? In my web application?
    I suppose I have to define it somewhere?
    sorry when this sounds amateurish...

    Thanks a lot!!!

    N
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    249
    Rep Power
    14
    Yes, in your web app.

    But, I don't know how to do this stuff in PHP - you might want to check the manuals for this.
    Martijn Tonies
    Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle
    Upscene Productions
    http://www.upscene.com
  12. #7
  13. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    UK
    Posts
    17
    Rep Power
    0
    cheers. will do that, good old php dot net

IMN logo majestic logo threadwatch logo seochat tools logo