0

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • The `image` data type will be removed in a future version of SQL Server. Avoid using this data type in new development work, and plan to modify applications that currently use it. Use `varbinary(max)` instead. [See details here](http://msdn.microsoft.com/en-us/library/ms187993.aspx) – marc_s Apr 19 '20 at 12:44

2 Answers2

0

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.

sunero4
  • 820
  • 9
  • 29
0

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.

SZT
  • 1,771
  • 4
  • 26
  • 53