Home > MS SQL Development > Files to be stored in DB, how?? (MS SQL)

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

    
Guest


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.

Was this answer helpful ? Yes No   
Guest


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

Was this answer helpful ? Yes No   
Guest


Hi,



Quote:

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?

Was this answer helpful ? Yes No   
Guest


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

Was this answer helpful ? Yes No   
Guest


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.

Was this answer helpful ? Yes No   
Guest


cheers. will do that, good old php dot net

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2010 by Infoqu. All rights reserved