Reputation: 33
I'm fairly new to how sql works and I am learning. I'm working on an assignment where we have to search for movies on a database. I have the database search working but I am unsure how to load images onto my sql database. I looked online and most examples used 'bulk' but it does not work for me, I asked my professor and he said that I had to use a textbox but I do not fully understand it. An explanation or example could help.I'll attach a screenshot of my sql table that I'm working with. Am i able to add the image using query commands? or would I have to do it in asp? Database code
Upvotes: 0
Views: 118
Reputation: 37
Unless there is a very good reason for putting your images in a database, it is considered an anti-pattern or just bad design. You save the images to disk and store the information about the image including the (relative) path in the database. This will keep your database light and responsive and you can manage your images relatively easy. Looking at your datatable example, the field says imageLocation (not image) however you use datatype image (does that even exist ?) maybe change that to varchar(255)
Upvotes: 1
Reputation: 240
I looked at your table and it seams, you have a ImageLocation field.
Wouldn't it mean, you are supposed to store the path to your image file?
Than your ImageLocation field in Database would be simple string
not an Image
as in it's location on the server:
images/PulpFiction.png
You could use this path to display images in your views
<img src= "@Url.Content(Model.ImageLocation)" alt="Image" />
Though i am not sure if this is what you are required.
Upvotes: 1