Asked By:
joshua
in
Jquery
-
18 days ago
randy's Answer
If all you have is a URL you will have to use something like WebClient.DownloadData(url) to get it locally, keeping in mind a: it might not actually give you the image (referrer/auth checks etc), and b: copyright may apply.
Then it is simply a case of handing the byte[] to SQL server. You can pass a byte[] to a SqlParameter.Value, and for storage in SQL Server you can use the varbinary(max) type. I would also suggest storing the content-type that you get back from WebClient.ResponseHeaders, so you know what type of image it is.
Don't use the image data-type; that is obsoleted by varbinary(max):
ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.
Answered
18 days ago |
Read Comments (2)
Read answer