0

I have visual studio 2010 with sql express. Im trying to create a asp website that will display a file from a database, and need to insert a textfile or pdf into the database table, can this be done using the visual interface, all the intructions i have found is only using the sql insert command?

Thanks

Genny Saxo
  • 35
  • 1
  • 6
  • What do you mean with visual interface, I mean, you must have a file upload control, that's not enough visual ? – crassr3cords Jun 14 '12 at 14:42
  • If you mean via the edit top 200 rows UI thingy in Sql Server Manager studio type manouver. Text type column might work for a text file (pdf is very unlikely) Image type is a no. Pretty much has to be write some code this. Another way to do this is to put the file name in the table, then get your asp to load the file and pass it back to the client. – Tony Hopkinson Jun 14 '12 at 14:50
  • Ive got the data type as varbinary(max) i read that its the better one for a text file? a pdf is not important, any type of text file will do. The file upload control is for the website for a user to upload a file? thats not what im looking for, i need to put the file in the table thats all. When i said visual interface i meant the access look, rather than creating and inserting via the sql language. – Genny Saxo Jun 14 '12 at 15:02
  • "When i said visual interface i meant the access look" - I thought you were using VS 2010 & SQL Express? Do you mean SQL Server Management Studio? If so, then no there isn't a way to do that that I'm aware of. Read [this post](http://stackoverflow.com/questions/1643627/how-to-insert-a-blob-into-a-database-using-sql-server-management-studio) for SQL-based answer. – bluevector Jun 14 '12 at 16:53

1 Answers1

0

No you can't do this. Basic UI interface means you can type it in, you can't type in an array of byte.

So that means code, it's not hard, but I would recommend you consider storing the a url / filename in the table and then putting the file on the file system instead of as a blob in the table.

Files in database blobs does have some benefits for local deployment, in that you don't have to worry about some muppet making them inaccessible. Server side though that is far less of a worry. As long as you back up database and file system and come up with a reasonable directory and file naming structure its much less of a cost than bloating a database with a load of stuff you can't use in a query, not to mention it tends to make a fair mess of volume (mdb) file.

Oh and there are persistant rumours that MS are going to drop blobs over 8000 bytes as well.

Tony Hopkinson
  • 20,172
  • 3
  • 31
  • 39