MySQL storing images using hyperlinks - c#

Good Day. So I have a question about storing images in Mysql.
My professor told us to change the data type of our column from blob to text.
And told us to store our images in a folder and not in the database itself and
just create a link stored in the column with the data type of text to link it to the directory of the images I want to show up in the db.
I don't know how to do it. I don't know how to use PHP.
My group is coding in C#.
Thank you!

Assume you are saving images in a directory /your_project/images/image_name.png
Then just save the relative path in your database like 'images/image_name.png'.
And when you need to fetch that image then just get this value and prep-and it with your main directory_name like www.site_name.com/images/image_name.png
You can change your main path when you move server .

Related

WPF: How to save image in SQL Server type as image?

I'm trying to save an image to the database (SQL Server) using WPF. Every solution on web is for WinApp.
I can't find some className or namespace in theirs.
Please help me!
Thanks.
I don't think there is an explicit "image" type in sql server. If you want to store your image in sql server you can store it as binary using the varbinary type: https://learn.microsoft.com/en-us/sql/connect/jdbc/using-advanced-data-types?view=sql-server-ver15
However, I think the most common solution to storing images might be to use some other sort of file storage, and just store the url to where the image is stored in the sql database.
Better practice for this would be to save the image in a storage/cdn and use resource id or url to load the image by the client.
You can see this post for why NOT storing image in database might be a good idea.
However if you really need to store image in DB, consider using a BLOB column and storing the image to it.

Add a video to a data table in visual studio

Am I able to add a video to a data table in my local db. And if so what would be the data type. I am using a file upload controller to upload the videos and I have 3 fields the title, category & description. Is that the best practice or is there some other/better way of doing it?
Any help appreciated
Thanks
Why you want to save whole of your file into database?
You can only save the path of uploaded video to your database and fetch from the path when needed.

Storing references to images in SQL Server using ASP.NET and C#

I am trying to store references of images in a SQL Server DB and store the actual images in a file server/folder. I am hoping someone could give me a link or code example on how to do this. I don't want to store BLOB in the database.
I am using ASP.NET/C# to handle this.
All files in a folder have unique names, so I think you shouldn't worry about storing the path of the image, as suggested in the comments. If you are worried about consistence, i.e. someone deleting a "referenced" image or inserting a path to nonexistent image file, you could check that either from your application, or even from the database itself.
However I would not hesitate to use a blob, you can use MS SQL 2012 and insert the image files to a file table, which sounds quite convenient.
as per my knowledge.or my expirence the images are stored in sql server that is in image datatype feild.it is stored in byte format.that is actlly the reference of the actual image.hope this link help you to get more clear idea about it
http://www.sqlhub.com/2009/03/image-store-in-sql-server-2005-database.html
http://www.codeproject.com/Articles/10861/Storing-and-Retrieving-Images-from-SQL-Server-usin
Use a HttpHandler to grab the image from the database and use the Image data type:
Retrieve image of image control as byte array which is set using generichandler(.ashx)?
Storing images in your dataase or in a filestream, totaly depends on your images size. In Microsoft Research there is a good paper called To BLOB or Not To BLOB.
After a lot of test and much analysis;
If your pictures are below 256K, store them in datebase VARBINARY column is good.
If your pictures are over 1 MB, storing them in the filesystem is good.(With FILESTREAM attribute, they are still under transactional control and part of the your database)

MS Access, SQL Server image field

I have spent nearly 2 days in trying to figure this out. We have an Access Project (adp) from Year 2000 that stores images to SQL Server 2008. I have tried connecting directly to SQL Server and to open TIFF files but it didn't work. Also tried to copy/paste the image field content into a file, renaming as TIFF and trying to open it but it didn't work as well. The problem with the content in the image field is that it is not of the right size. It is only 15-20KB but the files at that point should be around 3MB. It works fine if I retrieve the same data back in to the ACCESS project application.
I have tried TiffLib.net and few other things.
So, has anyone got any idea on how to migrate those image fields into SQL?
Thanks
Well the Image data type stores a binary version of your image.
Now the conversion process is explain in the below links.
You'll need to use a library to convert a byte array into image object.
http://www.akadia.com/services/dotnet_load_blob.html
http://www.dreamincode.net/forums/topic/103960-save-and-retrieve-images-with-sql-server/
Hopefully this helps.

getting binary format for displaying image in datagridview

i am currently facing some problem retrieving image for display on a datagridview control.
The Image data type in the database is blob.
I am using mysql as a database for retrieving the image . may i ask if it is possible to just retrieve a image data of this format and display in the gridview? or do i need to store the image in a image folder for retrieval?
I am using winforms application
Don't really think it's possible to figure out EXACT format of the image from its binary stream. The only solution I met, is storing the format in DB too, or have architectual convension to store in DB only one format type images.
Storing it in the local folder shall help you if you wish to reload it again later provided the DB isnt modified. Other wise i dont see any benefits here. Some times DB access is faster.

Categories